rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
Emin, Emax = context.Emin, context.Emax Etop = context.Etop()
Emin = context.Emin
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if ans.adjusted() < Emin:
ans_adjusted = ans.adjusted() if ans_adjusted < Emin:
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax
else: Etop = context.Etop() if folddown and ans._exp > Etop:
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign)
ans = ans._rescale(Etop, context=context) else: Emax = context.Emax if ans_adjusted > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign)
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
ans = self._check_nans(context=context) if ans: return ans if self._isinfinity(): return Decimal(self)
def _round(self, prec=None, rounding=None, context=None): """Returns a rounded version of self.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
n = self._convert_other(n) if n._isinfinity() or n.adjusted() > 8: return context._raise_error(InvalidOperation, 'x ** INF') ans = self._check_nans(n, context) if ans: return ans if not n._isinfinity() and not n._isinteger():
if self._is_special or n._is_special or n.adjusted() > 8: if n._isinfinity() or n.adjusted() > 8: return context._raise_error(InvalidOperation, 'x ** INF') ans = self._check_nans(n, context) if ans: return ans if not n._isinteger():
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo)
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
other = self._convert_other(other)
other = _convert_other(other)
def __rpow__(self, other, context=None): """Swaps self/other and returns __pow__.""" other = self._convert_other(other) return other.__pow__(self, context=context)
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if context is None: context = getcontext() ans = self._check_nans(context=context) if ans: return ans
if self._is_special: ans = self._check_nans(context=context) if ans: return ans
def normalize(self, context=None): """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" if context is None: context = getcontext()
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if context is None: context = getcontext() ans = self._check_nans(exp, context) if ans: return ans if exp._isinfinity() or self._isinfinity(): if exp._isinfinity() and self._isinfinity(): return self return context._raise_error(InvalidOperation, 'quantize with one INF')
if self._is_special or exp._is_special: ans = self._check_nans(exp, context) if ans: return ans if exp._isinfinity() or self._isinfinity(): if exp._isinfinity() and self._isinfinity(): return self if context is None: context = getcontext() return context._raise_error(InvalidOperation, 'quantize with one INF')
def quantize(self, exp, rounding = None, context=None, watchexp = 1): """Quantize self so its exponent is the same as that of exp.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if self._isnan() or other._isnan(): return self._isnan() and other._isnan() and True if self._isinfinity() or other._isinfinity(): return self._isinfinity() and other._isinfinity() and True
if self._is_special or other._is_special: if self._isnan() or other._isnan(): return self._isnan() and other._isnan() and True if self._isinfinity() or other._isinfinity(): return self._isinfinity() and other._isinfinity() and True
def same_quantum(self, other): """Test whether self and other have the same exponent.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if self._isinfinity(): return context._raise_error(InvalidOperation, 'rescale with an INF') ans = self._check_nans(context=context) if ans: return ans
if self._is_special: if self._isinfinity(): return context._raise_error(InvalidOperation, 'rescale with an INF') ans = self._check_nans(context=context) if ans: return ans
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if tmp and tmp.adjusted() < context.Emin:
tmp_adjusted = tmp.adjusted() if tmp and tmp_adjusted < context.Emin:
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
elif tmp and tmp.adjusted() > context.Emax:
elif tmp and tmp_adjusted > context.Emax:
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
ans = self._check_nans(context=context) if ans: return ans if self._exp >= 0: return self
def to_integral(self, rounding = None, context=None): """Rounds to the nearest integer, without raising inexact, rounded.""" if context is None: context = getcontext() ans = self._check_nans(context=context) if ans: return ans if self._exp >= 0: return self flags = context._ignore_flags(Rounded, Inexact) ans = self._rescale(0, rounding, context=context) context._regard_flags(flags) return ans
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if context is None: context = getcontext() ans = self._check_nans(context=context) if ans: return ans
if self._is_special: ans = self._check_nans(context=context) if ans: return ans if self._isinfinity() and self._sign == 0: return Decimal(self)
def sqrt(self, context=None): """Return the square root of self.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if self._isinfinity(): return Decimal(self)
def sqrt(self, context=None): """Return the square root of self.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if context is None: context = getcontext() other = self._convert_other(other) sn = self._isnan() on = other._isnan() if sn or on: if on == 1 and sn != 2: return self if sn == 1 and on != 2: return other return self._check_nans(other, context)
other = _convert_other(other) if self._is_special or other._is_special: sn = self._isnan() on = other._isnan() if sn or on: if on == 1 and sn != 2: return self if sn == 1 and on != 2: return other return self._check_nans(other, context)
def max(self, other, context=None): """Returns the larger value.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if context is None: context = getcontext() other = self._convert_other(other) sn = self._isnan() on = other._isnan() if sn or on: if on == 1 and sn != 2: return self if sn == 1 and on != 2: return other return self._check_nans(other, context)
other = _convert_other(other) if self._is_special or other._is_special: sn = self._isnan() on = other._isnan() if sn or on: if on == 1 and sn != 2: return self if sn == 1 and on != 2: return other return self._check_nans(other, context)
def min(self, other, context=None): """Returns the smaller value.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
def to_integral(self, a): """Rounds to an integer.
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
self.int = []
self.int = 0
def __init__(self, value=None): if value is None: self.sign = None self.int = [] self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 self.int = list(value._int) self.exp = value._exp if isinstance(value, tuple): self.sign = value[0] self.int = value[1] self.exp = value[2]
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
self.int = list(value._int)
cum = 0 for digit in value._int: cum = cum * 10 + digit self.int = cum
def __init__(self, value=None): if value is None: self.sign = None self.int = [] self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 self.int = list(value._int) self.exp = value._exp if isinstance(value, tuple): self.sign = value[0] self.int = value[1] self.exp = value[2]
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if len(int1) > len(int2):
if int1 > int2:
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direction * 1 if len(int1) < len(int2): return direction * -1 for i in xrange(len(int1)): if int1[i] > int2[i]: return direction * 1 if int1[i] < int2[i]: return direction * -1 return 0
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if len(int1) < len(int2):
if int1 < int2:
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direction * 1 if len(int1) < len(int2): return direction * -1 for i in xrange(len(int1)): if int1[i] > int2[i]: return direction * 1 if int1[i] < int2[i]: return direction * -1 return 0
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
for i in xrange(len(int1)): if int1[i] > int2[i]: return direction * 1 if int1[i] < int2[i]: return direction * -1
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direction * 1 if len(int1) < len(int2): return direction * -1 for i in xrange(len(int1)): if int1[i] > int2[i]: return direction * 1 if int1[i] < int2[i]: return direction * -1 return 0
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
def _increment(self): curspot = len(self.int) - 1 self.int[curspot]+= 1 while (self.int[curspot] >= 10): self.int[curspot] -= 10 if curspot == 0: self.int[0:0] = [1] break self.int[curspot-1] += 1 curspot -= 1 def subtract(self, alist): """Subtract a list from the current int (in place). It is assured that (len(list) = len(self.int) and list < self.int) or len(list) = len(self.int)-1 (i.e. that int(join(list)) < int(join(self.int))) """ selfint = self.int selfint.reverse() alist.reverse() carry = 0 for x in xrange(len(alist)): selfint[x] -= alist[x] + carry if selfint[x] < 0: carry = 1 selfint[x] += 10 else: carry = 0 if carry: selfint[x+1] -= 1 last = len(selfint)-1 while len(selfint) > 1 and selfint[last] == 0: last -= 1 if last == 0: break selfint[last+1:]=[] selfint.reverse() alist.reverse() return
def _increment(self): curspot = len(self.int) - 1 self.int[curspot]+= 1 while (self.int[curspot] >= 10): self.int[curspot] -= 10 if curspot == 0: self.int[0:0] = [1] break self.int[curspot-1] += 1 curspot -= 1
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if shouldround and numdigits > len(other.int) + prec + 1 -len(tmp.int): extend = prec + 2 -len(tmp.int) if extend <= 0: extend = 1 tmp.int.extend([0]*extend) tmp.exp -= extend other.int[:] = [0]*(len(tmp.int)-1)+[1] other.exp = tmp.exp return op1, op2 tmp.int.extend([0] * numdigits) tmp.exp = tmp.exp - numdigits numdigits = len(op1.int) - len(op2.int) if numdigits < 0: numdigits = -numdigits tmp = op1 else: tmp = op2 tmp.int[0:0] = [0] * numdigits
if shouldround and numdigits > prec + 1: tmp_len = len(str(tmp.int)) other_len = len(str(other.int)) if numdigits > (other_len + prec + 1 - tmp_len): extend = prec + 2 - tmp_len if extend <= 0: extend = 1 tmp.int *= 10 ** extend tmp.exp -= extend other.int = 1 other.exp = tmp.exp return op1, op2 tmp.int *= 10 ** numdigits tmp.exp -= numdigits
def _normalize(op1, op2, shouldround = 0, prec = 0): """Normalizes op1, op2 to have the same exp and length of coefficient. Done during addition. """ # Yes, the exponent is a long, but the difference between exponents # must be an int-- otherwise you'd get a big memory problem. numdigits = int(op1.exp - op2.exp) if numdigits < 0: numdigits = -numdigits tmp = op2 other = op1 else: tmp = op1 other = op2 if shouldround and numdigits > len(other.int) + prec + 1 -len(tmp.int): # If the difference in adjusted exps is > prec+1, we know # other is insignificant, so might as well put a 1 after the precision. # (since this is only for addition.) Also stops MemoryErrors. extend = prec + 2 -len(tmp.int) if extend <= 0: extend = 1 tmp.int.extend([0]*extend) tmp.exp -= extend other.int[:] = [0]*(len(tmp.int)-1)+[1] other.exp = tmp.exp return op1, op2 tmp.int.extend([0] * numdigits) tmp.exp = tmp.exp - numdigits numdigits = len(op1.int) - len(op2.int) # numdigits != 0 => They have the same exponent, but not the same length # of the coefficient. if numdigits < 0: numdigits = -numdigits tmp = op1 else: tmp = op2 tmp.int[0:0] = [0] * numdigits return op1, op2
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
"""Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int.
"""Adjust op1, op2 so that op2.int * 10 > op1.int >= op2.int.
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int) - len(op1.int) op1.int.extend([0]*diff) op1.exp -= diff adjust = diff #Same length, wrong order if len(op1.int) == len(op2.int) and op1.int < op2.int: op1.int.append(0) op1.exp -= 1 adjust+= 1 return op1, op2, adjust if len(op1.int) > len(op2.int) + 1: diff = len(op1.int) - len(op2.int) - 1 op2.int.extend([0]*diff) op2.exp -= diff adjust -= diff if len(op1.int) == len(op2.int)+1 and op1.int > op2.int: op2.int.append(0) op2.exp -= 1 adjust -= 1 return op1, op2, adjust
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
if len(op2.int) > len(op1.int): diff = len(op2.int) - len(op1.int) op1.int.extend([0]*diff) op1.exp -= diff adjust = diff if len(op1.int) == len(op2.int) and op1.int < op2.int: op1.int.append(0)
while op2.int > op1.int: op1.int *= 10
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int) - len(op1.int) op1.int.extend([0]*diff) op1.exp -= diff adjust = diff #Same length, wrong order if len(op1.int) == len(op2.int) and op1.int < op2.int: op1.int.append(0) op1.exp -= 1 adjust+= 1 return op1, op2, adjust if len(op1.int) > len(op2.int) + 1: diff = len(op1.int) - len(op2.int) - 1 op2.int.extend([0]*diff) op2.exp -= diff adjust -= diff if len(op1.int) == len(op2.int)+1 and op1.int > op2.int: op2.int.append(0) op2.exp -= 1 adjust -= 1 return op1, op2, adjust
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
adjust+= 1 return op1, op2, adjust if len(op1.int) > len(op2.int) + 1: diff = len(op1.int) - len(op2.int) - 1 op2.int.extend([0]*diff) op2.exp -= diff adjust -= diff if len(op1.int) == len(op2.int)+1 and op1.int > op2.int: op2.int.append(0)
adjust += 1 while op1.int >= (10 * op2.int): op2.int *= 10
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int) - len(op1.int) op1.int.extend([0]*diff) op1.exp -= diff adjust = diff #Same length, wrong order if len(op1.int) == len(op2.int) and op1.int < op2.int: op1.int.append(0) op1.exp -= 1 adjust+= 1 return op1, op2, adjust if len(op1.int) > len(op2.int) + 1: diff = len(op1.int) - len(op2.int) - 1 op2.int.extend([0]*diff) op2.exp -= diff adjust -= diff if len(op1.int) == len(op2.int)+1 and op1.int > op2.int: op2.int.append(0) op2.exp -= 1 adjust -= 1 return op1, op2, adjust
1a63da64df2af26e1f050749c19281f1de9084fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a63da64df2af26e1f050749c19281f1de9084fa/decimal.py
headers = {'content-type': "application/x-www-form-urlencoded"}
headers = {} if method == 'POST': headers['content-type'] = "application/x-www-form-urlencoded"
def __init__(self, fp=None, headers=None, outerboundary="", environ=os.environ, keep_blank_values=0, strict_parsing=0): """Constructor. Read multipart/* until last part.
a53bc7a43e08e09a2ce3643ce127d69f9fd43fce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a53bc7a43e08e09a2ce3643ce127d69f9fd43fce/cgi.py
try: _os.unlink(self._bakfile) except _os.error:
try: self._os.unlink(self._bakfile) except self._os.error:
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
863436289629bb2b61793d31043d8e32bfeba1c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/863436289629bb2b61793d31043d8e32bfeba1c3/dumbdbm.py
_os.rename(self._dirfile, self._bakfile) except _os.error:
self._os.rename(self._dirfile, self._bakfile) except self._os.error:
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
863436289629bb2b61793d31043d8e32bfeba1c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/863436289629bb2b61793d31043d8e32bfeba1c3/dumbdbm.py
f = _open(self._dirfile, 'w', self._mode)
f = self._open(self._dirfile, 'w', self._mode)
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass
863436289629bb2b61793d31043d8e32bfeba1c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/863436289629bb2b61793d31043d8e32bfeba1c3/dumbdbm.py
def __init__(self, file):
def __init__(self, file, mode): self._mode = mode
def __init__(self, file): self._dirfile = file + _os.extsep + 'dir' self._datfile = file + _os.extsep + 'dat' self._bakfile = file + _os.extsep + 'bak' # Mod by Jack: create data file if needed try: f = _open(self._datfile, 'r') except IOError: f = _open(self._datfile, 'w') f.close() self._update()
9a4db735787248d7f31c0dc487c69422200a5b4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9a4db735787248d7f31c0dc487c69422200a5b4a/dumbdbm.py
f = _open(self._datfile, 'w')
f = _open(self._datfile, 'w', self._mode)
def __init__(self, file): self._dirfile = file + _os.extsep + 'dir' self._datfile = file + _os.extsep + 'dat' self._bakfile = file + _os.extsep + 'bak' # Mod by Jack: create data file if needed try: f = _open(self._datfile, 'r') except IOError: f = _open(self._datfile, 'w') f.close() self._update()
9a4db735787248d7f31c0dc487c69422200a5b4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9a4db735787248d7f31c0dc487c69422200a5b4a/dumbdbm.py
f = _open(self._dirfile, 'w')
f = _open(self._dirfile, 'w', self._mode)
def _commit(self): try: _os.unlink(self._bakfile) except _os.error: pass try: _os.rename(self._dirfile, self._bakfile) except _os.error: pass f = _open(self._dirfile, 'w') for key, (pos, siz) in self._index.items(): f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) f.close()
9a4db735787248d7f31c0dc487c69422200a5b4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9a4db735787248d7f31c0dc487c69422200a5b4a/dumbdbm.py
f = _open(self._dirfile, 'a')
f = _open(self._dirfile, 'a', self._mode)
def _addkey(self, key, (pos, siz)): self._index[key] = (pos, siz) f = _open(self._dirfile, 'a') f.write("%s, (%s, %s)\n" % (`key`, `pos`, `siz`)) f.close()
9a4db735787248d7f31c0dc487c69422200a5b4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9a4db735787248d7f31c0dc487c69422200a5b4a/dumbdbm.py
print >> sys.stderr, _(__doc__) % globals()
print >> sys.stderr, __doc__ % globals()
def usage(code, msg=''): print >> sys.stderr, _(__doc__) % globals() if msg: print >> sys.stderr, msg sys.exit(code)
a8a3004c78ce436635ba5e2f5fba0b36c6134c7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a8a3004c78ce436635ba5e2f5fba0b36c6134c7b/pygettext.py
elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]: print >>sys.stderr, _('*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"') % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno} self.__state = self.__waiting
def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: self.__addentry(EMPTYSTRING.join(self.__data)) self.__state = self.__waiting elif ttype == tokenize.STRING: self.__data.append(safe_eval(tstring)) # TBD: should we warn if we seen anything else?
a8a3004c78ce436635ba5e2f5fba0b36c6134c7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a8a3004c78ce436635ba5e2f5fba0b36c6134c7b/pygettext.py
wid = WhichWindow(message)
if type(message) == type(1): wid = WhichWindow(message) else: wid = message
def do_activateEvt(self, event): (what, message, when, where, modifiers) = event wid = WhichWindow(message) if wid and self._windows.has_key(wid): window = self._windows[wid] window.do_activate(modifiers & 1, event) else: MacOS.HandleEvent(event)
3515afeb694530435e7a5403aab520356ac9cc74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3515afeb694530435e7a5403aab520356ac9cc74/FrameWork.py
self.do_activateEvt(self, nev)
self.do_activateEvt(nev)
def do_suspendresume(self, event): # Is this a good idea??? (what, message, when, where, modifiers) = event w = FrontWindow() if w: nev = (activateEvt, w, when, where, message&1) self.do_activateEvt(self, nev)
3515afeb694530435e7a5403aab520356ac9cc74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3515afeb694530435e7a5403aab520356ac9cc74/FrameWork.py
name = self.menu.GetItem(item)
name = self.menu.GetMenuItemText(item)
def dispatch(self, id, item, window, event): if item == 1: Menu.dispatch(self, id, item, window, event) else: name = self.menu.GetItem(item) OpenDeskAcc(name)
3515afeb694530435e7a5403aab520356ac9cc74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3515afeb694530435e7a5403aab520356ac9cc74/FrameWork.py
def open(self): self.wid = NewWindow((40, 40, 400, 400), self.__class__.__name__, 1,
def open(self, bounds=(40, 40, 400, 400), resid=None): if resid <> None: self.wid = GetNewWindow(resid, -1) else: self.wid = NewWindow(bounds, self.__class__.__name__, 1,
def open(self): self.wid = NewWindow((40, 40, 400, 400), self.__class__.__name__, 1, 0, -1, 1, 0) self.do_postopen()
3515afeb694530435e7a5403aab520356ac9cc74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3515afeb694530435e7a5403aab520356ac9cc74/FrameWork.py
Continuation are represented by an embedded newline then
Continuations are represented by an embedded newline then
def _read(self, fp, fpname): """Parse a sectioned setup file.
089c5cb7fb1645b5e044d4fd127243c4a563b500 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/089c5cb7fb1645b5e044d4fd127243c4a563b500/ConfigParser.py
and just about everything else is ignored.
and just about everything else are ignored.
def _read(self, fp, fpname): """Parse a sectioned setup file.
089c5cb7fb1645b5e044d4fd127243c4a563b500 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/089c5cb7fb1645b5e044d4fd127243c4a563b500/ConfigParser.py
labels = doc.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) parent.removeChild(label)
for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) parent.removeChild(label)
def handle_labels(doc): labels = doc.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.setAttribute("id", id) # now, remove <label id="..."/> from parent: parent.removeChild(label)
52aacc885ae24e45f709ae53165e5458edcdfa1c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/52aacc885ae24e45f709ae53165e5458edcdfa1c/docfixer.py
if a.index(-2,-10) != 0: raise TestFailed, 'list index, negative start argument'
if a.index(0,-4) != 2: raise TestFailed, 'list index, -start argument' if a.index(-2,-10) != 0: raise TestFailed, 'list index, very -start argument'
def __getitem__(self, key): return str(key) + '!!!'
e618d3051dd46bc547d5524bef5e38ece3f4bc7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e618d3051dd46bc547d5524bef5e38ece3f4bc7a/test_types.py
raise TestFailed, 'list index, negative stop argument'
raise TestFailed, 'list index, very -stop argument'
def __getitem__(self, key): return str(key) + '!!!'
e618d3051dd46bc547d5524bef5e38ece3f4bc7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e618d3051dd46bc547d5524bef5e38ece3f4bc7a/test_types.py
self._file.write(struct.pack('<lsslhhllhhs',
self._file.write(struct.pack('<l4s4slhhllhh4s',
def _write_header(self, initlength): self._file.write('RIFF') if not self._nframes: self._nframes = initlength / (self._nchannels * self._sampwidth) self._datalength = self._nframes * self._nchannels * self._sampwidth self._form_length_pos = self._file.tell() self._file.write(struct.pack('<lsslhhllhhs', 36 + self._datalength, 'WAVE', 'fmt ', 16, WAVE_FORMAT_PCM, self._nchannels, self._framerate, self._nchannels * self._framerate * self._sampwidth, self._nchannels * self._sampwidth, self._sampwidth * 8, 'data')) self._data_length_pos = self._file.tell() self._file.write(struct.pack('<l', self._datalength))
c4c979408f7ddda3df3dcbf147cffdc1b58cbcc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c4c979408f7ddda3df3dcbf147cffdc1b58cbcc0/wave.py
return swi.swi('OS_File', '5s;i', p)!=0
try: return swi.swi('OS_File', '5s;i', p)!=0 except swi.error: return 0
def exists(p): """
d0c0df26cac549315c63e10897fe91b6c25a2da5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0c0df26cac549315c63e10897fe91b6c25a2da5/riscospath.py
return swi.swi('OS_File', '5s;i', p) in [2, 3]
try: return swi.swi('OS_File', '5s;i', p) in [2, 3] except swi.error: return 0
def isdir(p): """
d0c0df26cac549315c63e10897fe91b6c25a2da5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0c0df26cac549315c63e10897fe91b6c25a2da5/riscospath.py
return swi.swi('OS_File', '5s;i', p) in [1, 3]
try: return swi.swi('OS_File', '5s;i', p) in [1, 3] except swi.error: return 0
def isfile(p): """
d0c0df26cac549315c63e10897fe91b6c25a2da5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d0c0df26cac549315c63e10897fe91b6c25a2da5/riscospath.py
print mod.__name__, dir(mod)
def parseargs(): global DEBUGSTREAM try: opts, args = getopt.getopt( sys.argv[1:], 'nVhc:d', ['class=', 'nosetuid', 'version', 'help', 'debug']) except getopt.error, e: usage(1, e) options = Options() for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-V', '--version'): print >> sys.stderr, __version__ sys.exit(0) elif opt in ('-n', '--nosetuid'): options.setuid = 0 elif opt in ('-c', '--class'): options.classname = arg elif opt in ('-d', '--debug'): DEBUGSTREAM = sys.stderr # parse the rest of the arguments if len(args) < 1: localspec = 'localhost:8025' remotespec = 'localhost:25' elif len(args) < 2: localspec = args[0] remotespec = 'localhost:25' elif len(args) < 3: localspec = args[0] remotespec = args[1] else: usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args)) # split into host/port pairs i = localspec.find(':') if i < 0: usage(1, 'Bad local spec: %s' % localspec) options.localhost = localspec[:i] try: options.localport = int(localspec[i+1:]) except ValueError: usage(1, 'Bad local port: %s' % localspec) i = remotespec.find(':') if i < 0: usage(1, 'Bad remote spec: %s' % remotespec) options.remotehost = remotespec[:i] try: options.remoteport = int(remotespec[i+1:]) except ValueError: usage(1, 'Bad remote port: %s' % remotespec) return options
e5977d3d82076c245f9ab27223e79ff28fafbdda /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e5977d3d82076c245f9ab27223e79ff28fafbdda/smtpd.py
class Element( Node ):
class Element(Node):
def __delitem__(self, attname_or_tuple): node = self[attname_or_tuple] node.unlink() del self._attrs[node.name] del self._attrsNS[(node.namespaceURI, node.localName)]
cb00847229af2d2e2e53f0a270dc183fd7a75ccc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cb00847229af2d2e2e53f0a270dc183fd7a75ccc/minidom.py
print "File name %s contains a suspicious null byte!" % filename
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.orig_filename = filename # Original file name in archive
8e8fc7535056b6829b0bb8faaffb6f4ca3c681d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8e8fc7535056b6829b0bb8faaffb6f4ca3c681d5/zipfile.py
elif platform == 'cygwin': x11_inc = find_file('X11/Xlib.h', [], inc_dirs) if x11_inc is None: return
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
4f02c67ded0aea6ee8770349277c7282f3ef67e7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4f02c67ded0aea6ee8770349277c7282f3ef67e7/setup.py
if __name__ == "__main__": import __main__ sys.modules['warnings'] = __main__ _test() else: _processoptions(sys.warnoptions) simplefilter("ignore", category=OverflowWarning, append=1) simplefilter("ignore", category=PendingDeprecationWarning, append=1)
_processoptions(sys.warnoptions) simplefilter("ignore", category=OverflowWarning, append=1) simplefilter("ignore", category=PendingDeprecationWarning, append=1)
def _getcategory(category): import re if not category: return Warning if re.match("^[a-zA-Z0-9_]+$", category): try: cat = eval(category) except NameError: raise _OptionError("unknown warning category: %r" % (category,)) else: i = category.rfind(".") module = category[:i] klass = category[i+1:] try: m = __import__(module, None, None, [klass]) except ImportError: raise _OptionError("invalid module name: %r" % (module,)) try: cat = getattr(m, klass) except AttributeError: raise _OptionError("unknown warning category: %r" % (category,)) if (not isinstance(cat, types.ClassType) or not issubclass(cat, Warning)): raise _OptionError("invalid warning category: %r" % (category,)) return cat
7ff5135213e829336773b9dd40a17baa8374ad6b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7ff5135213e829336773b9dd40a17baa8374ad6b/warnings.py
if 0: def test_timeout(): test_support.requires('network')
def test_timeout(): test_support.requires('network')
def test_basic(): test_support.requires('network') import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close()
434f65f13ffffefb35b4f9f22ef4beef59e466f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/434f65f13ffffefb35b4f9f22ef4beef59e466f6/test_socket_ssl.py
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(30.0) s.connect(("gmail.org", 995)) ss = socket.ssl(s) ss.read(1) ss.read(1) s.close() else: def test_timeout(): pass
if test_support.verbose: print "test_timeout ..." ADDR = "gmail.org", 995 s = socket.socket() s.settimeout(30.0) try: s.connect(ADDR) except socket.timeout: print >> sys.stderr, """\ WARNING: an attempt to connect to %r timed out, in test_timeout. That may be legitimate, but is not the outcome we hoped for. If this message is seen often, test_timeout should be changed to use a more reliable address.""" % (ADDR,) return ss = socket.ssl(s) ss.read(1) ss.read(1) s.close()
def test_timeout(): test_support.requires('network')
434f65f13ffffefb35b4f9f22ef4beef59e466f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/434f65f13ffffefb35b4f9f22ef4beef59e466f6/test_socket_ssl.py
containing the table) showing a side by side, line by line comparision
containing the table) showing a side by side, line by line comparison
def _line_pair_iterator(): """Yields from/to lines of text with a change indication.
7fbf8bc349f6402feeac31a579c0c070c85ef41a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7fbf8bc349f6402feeac31a579c0c070c85ef41a/difflib.py
cantset(f, "func_name", "f") cantset(f, "__name__", "f")
f.__name__ = "g" verify(f.__name__ == "g") verify(f.func_name == "g") f.func_name = "h" verify(f.__name__ == "h") verify(f.func_name == "h") cantset(f, "func_globals", 1) cantset(f, "__name__", 1)
def f(): pass
29f171dbe87cdb8b33ea181dac1d0a4927bff54e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/29f171dbe87cdb8b33ea181dac1d0a4927bff54e/test_funcattrs.py
self._parsing = 0
def reset(self): if self._namespaces: self._parser = expat.ParserCreate(None, " ") self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: self._parser = expat.ParserCreate() self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler = self.end_element
e4aa203a40a9278c701c689266bab0c246b7441b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e4aa203a40a9278c701c689266bab0c246b7441b/expatreader.py
verify(log == [('getattr', '__init__'), ('getattr', '__setattr__'),
verify(log == [('getattr', '__setattr__'),
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
6a642a8bd997275bf8c8cbaa9ae59cd351a9a269 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6a642a8bd997275bf8c8cbaa9ae59cd351a9a269/test_descr.py
e.delta = getint(D)
try: e.delta = getint(D) except ValueError: e.delta = 0
def _substitute(self, *args): """Internal function.""" if len(args) != len(self._subst_format): return args getboolean = self.tk.getboolean getint = int nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() e.serial = getint(nsign) e.num = getint(b) try: e.focus = getboolean(f) except TclError: pass e.height = getint(h) e.keycode = getint(k) # For Visibility events, event state is a string and # not an integer: try: e.state = getint(s) except ValueError: e.state = s e.time = getint(t) e.width = getint(w) e.x = getint(x) e.y = getint(y) e.char = A try: e.send_event = getboolean(E) except TclError: pass e.keysym = K e.keysym_num = getint(N) e.type = T try: e.widget = self._nametowidget(W) except KeyError: e.widget = W e.x_root = getint(X) e.y_root = getint(Y) e.delta = getint(D) return (e,)
664ac9ab0814513a92495ffc8f5f1cb5a75177a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/664ac9ab0814513a92495ffc8f5f1cb5a75177a9/Tkinter.py
print socket.getservbyname('telnet', 'tcp') try: socket.getservbyname('telnet', 'udp') except socket.error: pass
if hasattr(socket, 'getservbyname'): print socket.getservbyname('telnet', 'tcp') try: socket.getservbyname('telnet', 'udp') except socket.error: pass
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
a519032526fb7a400f85b169e2a94016a202c4cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a519032526fb7a400f85b169e2a94016a202c4cc/test_socket.py
libraries=[dblib]))
libraries=dblibs))
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
libraries=[dblib]))
libraries=dblibs))
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
if platform not in ['cygwin', 'mac']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'ndbm') and find_file("ndbm.h", inc_dirs, []) is not None):
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
elif (platform in ['darwin'] and find_file("ndbm.h", inc_dirs, []) is not None):
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
library_dirs=dblib_dir,
library_dirs=[dblib_dir],
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
else: exts.append( Extension('dbm', ['dbmmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
frameworkdir = sysconfig.get_config_var('PYTHONFRAMEWORKDIR') exts.append( Extension('gestalt', ['gestaltmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
exts.append( Extension('_Res', ['res/_Resmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) ) if frameworkdir:
framework = sysconfig.get_config_var('PYTHONFRAMEWORK') if framework: exts.append( Extension('gestalt', ['gestaltmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
["../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)])
[ "../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)])
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
6c8af65295229596ada11221e47a0cd074a5df45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6c8af65295229596ada11221e47a0cd074a5df45/setup.py
_keep_alive(args, memo)
def _deepcopy_inst(x, memo): if hasattr(x, '__deepcopy__'): return x.__deepcopy__(memo) if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() _keep_alive(args, memo) args = deepcopy(args, memo) y = apply(x.__class__, args) else: y = _EmptyClass() y.__class__ = x.__class__ memo[id(x)] = y if hasattr(x, '__getstate__'): state = x.__getstate__() _keep_alive(state, memo) else: state = x.__dict__ state = deepcopy(state, memo) if hasattr(y, '__setstate__'): y.__setstate__(state) else: y.__dict__.update(state) return y
166879d4a9363165c66fc150f42212e35807d556 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/166879d4a9363165c66fc150f42212e35807d556/copy.py
_keep_alive(state, memo)
def _deepcopy_inst(x, memo): if hasattr(x, '__deepcopy__'): return x.__deepcopy__(memo) if hasattr(x, '__getinitargs__'): args = x.__getinitargs__() _keep_alive(args, memo) args = deepcopy(args, memo) y = apply(x.__class__, args) else: y = _EmptyClass() y.__class__ = x.__class__ memo[id(x)] = y if hasattr(x, '__getstate__'): state = x.__getstate__() _keep_alive(state, memo) else: state = x.__dict__ state = deepcopy(state, memo) if hasattr(y, '__setstate__'): y.__setstate__(state) else: y.__dict__.update(state) return y
166879d4a9363165c66fc150f42212e35807d556 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/166879d4a9363165c66fc150f42212e35807d556/copy.py
def clear(self): self.fill(0) canvas = self._canvas items = self._items self._items = [] for item in items: canvas.delete(item) self._delete_turtle() self._draw_turtle()
62ced6be422a7035b6c20f5a19f3c76cb8e5750f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/62ced6be422a7035b6c20f5a19f3c76cb8e5750f/turtle.py
def _set_color(self,color): self._color = color self._draw_turtle()
62ced6be422a7035b6c20f5a19f3c76cb8e5750f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/62ced6be422a7035b6c20f5a19f3c76cb8e5750f/turtle.py
access *: private
if 0: access *: private
def close(self): self._ensure_header_written() if self._nframeswritten != self._nframes or \ self._datalength != self._datawritten: self._patchheader() self._file.flush() self._file = None
c0567b79e54024dd1c1fa1d2102623eb96163515 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c0567b79e54024dd1c1fa1d2102623eb96163515/sunau.py
def copytree(src, dst, symlinks=0):
def copytree(src, dst, symlinks=False):
def copytree(src, dst, symlinks=0): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. Error are reported to standard output. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) if errors: raise Error, errors
7e10798c71726bc88b0e76270bbfd67f6331b983 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7e10798c71726bc88b0e76270bbfd67f6331b983/shutil.py
Error are reported to standard output.
If exception(s) occur, an Error is raised with a list of reasons.
def copytree(src, dst, symlinks=0): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. Error are reported to standard output. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) if errors: raise Error, errors
7e10798c71726bc88b0e76270bbfd67f6331b983 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7e10798c71726bc88b0e76270bbfd67f6331b983/shutil.py
if issubclass(t, TypeType):
try: issc = issubclass(t, TypeType) except TypeError: issc = 0 if issc:
def save(self, object, pers_save = 0): memo = self.memo
3609c0a2d5d8175fa73783ee7f7b34c2af5e6eba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3609c0a2d5d8175fa73783ee7f7b34c2af5e6eba/pickle.py
self.pack_uint(int(x>>32 & 0xffffffff)) self.pack_uint(int(x & 0xffffffff))
self.pack_uint(x>>32 & 0xffffffffL) self.pack_uint(x & 0xffffffffL)
def pack_uhyper(self, x):
6eacc94e4bb4ec61ae8baed1f5af34c87aa2f4b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6eacc94e4bb4ec61ae8baed1f5af34c87aa2f4b0/xdrlib.py
elif path == '' or path[-1:] in '/\\':
elif path == '' or path[-1:] in '/\\:':
def join(a, *p): """Join two or more pathname components, inserting "\\" as needed""" path = a for b in p: if isabs(b): path = b elif path == '' or path[-1:] in '/\\': path = path + b else: path = path + os.sep + b return path
358944aa733dc84de985126ebb7e89e4b40caae6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/358944aa733dc84de985126ebb7e89e4b40caae6/ntpath.py
verify(self.cbcalled == 1, "callback did not properly set 'cbcalled'") verify(ref() is None, "ref2 should be dead after deleting object reference")
self.assert_(self.cbcalled == 1, "callback did not properly set 'cbcalled'") self.assert_(ref() is None, "ref2 should be dead after deleting object reference")
def check_basic_callback(self, factory): self.cbcalled = 0 o = factory() ref = weakref.ref(o, self.callback) del o verify(self.cbcalled == 1, "callback did not properly set 'cbcalled'") verify(ref() is None, "ref2 should be dead after deleting object reference")
9b516276c3f74feb4b1c6473ccd168fd0ae80656 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9b516276c3f74feb4b1c6473ccd168fd0ae80656/test_weakref.py
self.assertEqual(grp.getgrgid(e.gr_gid), e)
entriesbygid.setdefault(e.gr_gid, []).append(e) for e in entries: self.assert_(grp.getgrgid(e.gr_gid) in entriesbygid[e.gr_gid])
def test_values(self): entries = grp.getgrall()
41e3a5ba5eb38ecb2181a52ca3c96ba21b6ef136 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/41e3a5ba5eb38ecb2181a52ca3c96ba21b6ef136/test_grp.py
if type(url) in types.StringTypes:
if type(url) is types.StringType:
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) in types.StringTypes: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = base64.encodestring(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
2363faa41e92134dd7b079471e00a63f0ae5a270 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2363faa41e92134dd7b079471e00a63f0ae5a270/urllib.py
while cursel > 0 and selstart[:i] <= self.completions[cursel-1]:
previous_completion = self.completions[cursel - 1] while cursel > 0 and selstart[:i] <= previous_completion:
def _selection_changed(self): """Should be called when the selection of the Listbox has changed. Updates the Listbox display and calls _change_start.""" cursel = int(self.listbox.curselection()[0])
4af42e5efa9305cad82020fcaf2b091509ec733b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4af42e5efa9305cad82020fcaf2b091509ec733b/AutoCompleteWindow.py
print repr(str(err))
# def __getstate__(self):
95313a7fd88522faca5f127344250a6a8b65b526 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/95313a7fd88522faca5f127344250a6a8b65b526/pickle.py
return pydoc.getdoc(method)
import pydoc return pydoc.getdoc(method)
def system_methodHelp(self, method_name): """system.methodHelp('add') => "Adds two integers together"
74becf80fc30b1714a09e04cf1e42f4376a043e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74becf80fc30b1714a09e04cf1e42f4376a043e1/SimpleXMLRPCServer.py
sys.stdout.write(reponse)
sys.stdout.write(response)
def handle_get(self): """Handle a single HTTP GET request.
74becf80fc30b1714a09e04cf1e42f4376a043e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/74becf80fc30b1714a09e04cf1e42f4376a043e1/SimpleXMLRPCServer.py
socket.SOL_SOCKET, socket.SO_REUSEADDR,
socket.SOL_SOCKET, reuse_constant,
def set_reuse_addr(self): # try to re-use a server port if possible try: self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1 ) except socket.error: pass
83053b02af4b376c145d1b593f843f5352f677b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/83053b02af4b376c145d1b593f843f5352f677b1/asyncore.py
socket.SO_REUSEADDR) | 1
reuse_constant) | 1
def set_reuse_addr(self): # try to re-use a server port if possible try: self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1 ) except socket.error: pass
83053b02af4b376c145d1b593f843f5352f677b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/83053b02af4b376c145d1b593f843f5352f677b1/asyncore.py
def set_reuse_addr(self): # try to re-use a server port if possible try: self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1 ) except socket.error: pass
83053b02af4b376c145d1b593f843f5352f677b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/83053b02af4b376c145d1b593f843f5352f677b1/asyncore.py
def run(self): # remove the build/temp.<plat> directory (unless it's already # gone) if os.path.exists (self.build_temp): remove_tree (self.build_temp, self.verbose, self.dry_run) else: self.warn ("'%s' does not exist -- can't clean it" % self.build_temp)
fe967e1dd904fafb39501e2469b2ad1fef742314 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fe967e1dd904fafb39501e2469b2ad1fef742314/clean.py
if os.path.exists (self.build_lib): remove_tree (self.build_lib, self.verbose, self.dry_run) else: self.warn ("'%s' does not exist -- can't clean it" % self.build_lib) if os.path.exists (self.bdist_base): remove_tree (self.bdist_base, self.verbose, self.dry_run) else: self.warn ("'%s' does not exist -- can't clean it" % self.bdist_base)
for directory in (self.build_lib, self.bdist_base, self.build_scripts): if os.path.exists (directory): remove_tree (directory, self.verbose, self.dry_run) else: self.warn ("'%s' does not exist -- can't clean it" % directory)
def run(self): # remove the build/temp.<plat> directory (unless it's already # gone) if os.path.exists (self.build_temp): remove_tree (self.build_temp, self.verbose, self.dry_run) else: self.warn ("'%s' does not exist -- can't clean it" % self.build_temp)
fe967e1dd904fafb39501e2469b2ad1fef742314 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fe967e1dd904fafb39501e2469b2ad1fef742314/clean.py
if netloc:
if netloc or (scheme in uses_netloc and url[:2] == '//'):
def urlunparse((scheme, netloc, url, params, query, fragment)): if netloc: if url[:1] != '/': url = '/' + url url = '//' + netloc + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url
3fda52916e1478de54b9d1fb111742e3c30fe94f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3fda52916e1478de54b9d1fb111742e3c30fe94f/urlparse.py
url = '//' + netloc + url
url = '//' + (netloc or '') + url
def urlunparse((scheme, netloc, url, params, query, fragment)): if netloc: if url[:1] != '/': url = '/' + url url = '//' + netloc + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url
3fda52916e1478de54b9d1fb111742e3c30fe94f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3fda52916e1478de54b9d1fb111742e3c30fe94f/urlparse.py
sys.settrace(gself.lobaltrace)
sys.settrace(self.globaltrace)
def runctx(self, cmd, globals=None, locals=None): if globals is None: globals = {} if locals is None: locals = {} if not self.donothing: sys.settrace(gself.lobaltrace) try: exec cmd in dict, dict finally: if not self.donothing: sys.settrace(None)
11d6242ee8b30c5a8f3639283522c47d378dc063 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/11d6242ee8b30c5a8f3639283522c47d378dc063/trace.py