diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 5 | ||||
-rw-r--r-- | Lib/test/test_generators.py | 12 | ||||
-rw-r--r-- | Lib/zipfile.py | 4 |
3 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 481ca0f..a0958df 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -23,6 +23,11 @@ def testunop(a, res, expr="len(a)", meth="__len__"): def testbinop(a, b, res, expr="a+b", meth="__add__"): if verbose: print "checking", expr dict = {'a': a, 'b': b} + + # XXX Hack so this passes before 2.3 when -Qnew is specified. + if meth == "__div__" and 1/2 == 0.5: + meth = "__truediv__" + vereq(eval(expr, dict), res) t = type(a) m = getattr(t, meth) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 118b1d9..2c319e5 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -182,7 +182,7 @@ Specification: Return Specification: Generators and Exception Propagation >>> def f(): - ... return 1/0 + ... return 1//0 >>> def g(): ... yield f() # the zero division exception propagates ... yield 42 # and we'll never get here @@ -206,7 +206,7 @@ Specification: Try/Except/Finally ... yield 1 ... try: ... yield 2 - ... 1/0 + ... 1//0 ... yield 3 # never get here ... except ZeroDivisionError: ... yield 4 @@ -253,7 +253,7 @@ Guido's binary tree example. ... n = len(list) ... if n == 0: ... return [] - ... i = n / 2 + ... i = n // 2 ... return Tree(list[i], tree(list[:i]), tree(list[i+1:])) >>> # Show it off: create a tree. @@ -691,7 +691,7 @@ SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<stri >>> def f(): ... try: ... try: -... 1/0 +... 1//0 ... except ZeroDivisionError: ... yield 666 # bad because *outer* try has finally ... except: @@ -708,7 +708,7 @@ But this is fine: ... try: ... try: ... yield 12 -... 1/0 +... 1//0 ... except ZeroDivisionError: ... yield 666 ... except: @@ -751,7 +751,7 @@ SyntaxError: invalid syntax ... pass ... elif 0: ... try: -... 1/0 +... 1//0 ... except SyntaxError: ... pass ... else: diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 4b59ac6..0efcad3 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -117,7 +117,7 @@ class ZipInfo: """Return the per-file header as a string.""" dt = self.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] - dostime = dt[3] << 11 | dt[4] << 5 | dt[5] / 2 + dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2) if self.flag_bits & 0x08: # Set these to zero because we write them after the file data CRC = compress_size = file_size = 0 @@ -468,7 +468,7 @@ class ZipFile: count = count + 1 dt = zinfo.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] - dostime = dt[3] << 11 | dt[4] << 5 | dt[5] / 2 + dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2) centdir = struct.pack(structCentralDir, stringCentralDir, zinfo.create_version, zinfo.create_system, zinfo.extract_version, zinfo.reserved, |