[Python-checkins] r83540 - in python/branches/release26-maint: Lib/ctypes/test/test_pep3118.py Lib/ctypes/test/test_structures.py Lib/email/test/test_email.py Lib/email/test/test_email_renamed.py Lib/sqlite3/test/types.py Lib/sqlite3/test/userfunctions.py Lib/test/infinite_reload.py Lib/test/inspect_fodder.py Lib/test/regrtest.py Lib/test/test_binop.py Lib/test/test_compiler.py Lib/test/test_descrtut.py Lib/test/test_dict.py Lib/test/test_file.py Lib/test/test_ftplib.py Lib/test/test_functools.py Lib/test/test_grammar.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_inspect.py Lib/test/test_io.py Lib/test/test_itertools.py Lib/test/test_mutants.py Lib/test/test_opcodes.py Lib/test/test_optparse.py Lib/test/test_ossaudiodev.py Lib/test/test_pkgimport.py Lib/test/test_pyexpat.py Lib/test/test_queue.py Lib/test/test_random.py Lib/test/test_repr.py Lib/test/test_rfc822.py Lib/test/test_site.py Lib/test/test_sys.py Lib/test/test_threadsignals.py Lib/test/test_trace.py Lib/test/test_traceback.py Lib/test/test_with.py Lib/test/test_wsgiref.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py
ezio.melotti
python-checkins at python.org
Mon Aug 2 20:40:55 CEST 2010
Author: ezio.melotti
Date: Mon Aug 2 20:40:55 2010
New Revision: 83540
Log:
Merged revisions 77942,79023 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77942 | ezio.melotti | 2010-02-03 07:37:26 +0200 (Wed, 03 Feb 2010) | 1 line
#7092: Silence more py3k warnings. Patch by Florent Xicluna.
........
r79023 | ezio.melotti | 2010-03-17 15:52:48 +0200 (Wed, 17 Mar 2010) | 1 line
#7092: silence some more py3k warnings.
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/ctypes/test/test_pep3118.py
python/branches/release26-maint/Lib/ctypes/test/test_structures.py
python/branches/release26-maint/Lib/email/test/test_email.py
python/branches/release26-maint/Lib/email/test/test_email_renamed.py
python/branches/release26-maint/Lib/sqlite3/test/types.py
python/branches/release26-maint/Lib/sqlite3/test/userfunctions.py
python/branches/release26-maint/Lib/test/infinite_reload.py
python/branches/release26-maint/Lib/test/inspect_fodder.py
python/branches/release26-maint/Lib/test/regrtest.py
python/branches/release26-maint/Lib/test/test_binop.py
python/branches/release26-maint/Lib/test/test_compiler.py
python/branches/release26-maint/Lib/test/test_descrtut.py
python/branches/release26-maint/Lib/test/test_dict.py
python/branches/release26-maint/Lib/test/test_file.py
python/branches/release26-maint/Lib/test/test_ftplib.py
python/branches/release26-maint/Lib/test/test_functools.py
python/branches/release26-maint/Lib/test/test_grammar.py
python/branches/release26-maint/Lib/test/test_import.py
python/branches/release26-maint/Lib/test/test_importhooks.py
python/branches/release26-maint/Lib/test/test_inspect.py
python/branches/release26-maint/Lib/test/test_io.py
python/branches/release26-maint/Lib/test/test_itertools.py
python/branches/release26-maint/Lib/test/test_mutants.py
python/branches/release26-maint/Lib/test/test_opcodes.py
python/branches/release26-maint/Lib/test/test_optparse.py
python/branches/release26-maint/Lib/test/test_ossaudiodev.py
python/branches/release26-maint/Lib/test/test_pkgimport.py
python/branches/release26-maint/Lib/test/test_pyexpat.py
python/branches/release26-maint/Lib/test/test_queue.py
python/branches/release26-maint/Lib/test/test_random.py
python/branches/release26-maint/Lib/test/test_repr.py
python/branches/release26-maint/Lib/test/test_rfc822.py
python/branches/release26-maint/Lib/test/test_site.py
python/branches/release26-maint/Lib/test/test_sys.py
python/branches/release26-maint/Lib/test/test_threadsignals.py
python/branches/release26-maint/Lib/test/test_trace.py
python/branches/release26-maint/Lib/test/test_traceback.py
python/branches/release26-maint/Lib/test/test_with.py
python/branches/release26-maint/Lib/test/test_wsgiref.py
python/branches/release26-maint/Lib/test/test_xml_etree.py
python/branches/release26-maint/Lib/test/test_xml_etree_c.py
Modified: python/branches/release26-maint/Lib/ctypes/test/test_pep3118.py
==============================================================================
--- python/branches/release26-maint/Lib/ctypes/test/test_pep3118.py (original)
+++ python/branches/release26-maint/Lib/ctypes/test/test_pep3118.py Mon Aug 2 20:40:55 2010
@@ -24,7 +24,7 @@
else:
size = sizeof(ob)
for dim in self.shape:
- size /= dim
+ size //= dim
self.itemsize = size
self.strides = None
self.readonly = False
Modified: python/branches/release26-maint/Lib/ctypes/test/test_structures.py
==============================================================================
--- python/branches/release26-maint/Lib/ctypes/test/test_structures.py (original)
+++ python/branches/release26-maint/Lib/ctypes/test/test_structures.py Mon Aug 2 20:40:55 2010
@@ -367,11 +367,11 @@
_fields_ = [("d", c_int), ("e", c_int), ("f", c_int)]
z = Z(1, 2, 3, 4, 5, 6)
- self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f),
- (1, 2, 3, 4, 5, 6))
+ self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f),
+ (1, 2, 3, 4, 5, 6))
z = Z(1)
- self.failUnlessEqual((z.a, z.b, z.c, z.d, z.e, z.f),
- (1, 0, 0, 0, 0, 0))
+ self.assertEqual((z.a, z.b, z.c, z.d, z.e, z.f),
+ (1, 0, 0, 0, 0, 0))
self.assertRaises(TypeError, lambda: Z(1, 2, 3, 4, 5, 6, 7))
class PointerMemberTestCase(unittest.TestCase):
Modified: python/branches/release26-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release26-maint/Lib/email/test/test_email.py (original)
+++ python/branches/release26-maint/Lib/email/test/test_email.py Mon Aug 2 20:40:55 2010
@@ -1086,7 +1086,7 @@
sign = '-'
else:
sign = '+'
- tzoffset = ' %s%04d' % (sign, tzsecs / 36)
+ tzoffset = ' %s%04d' % (sign, tzsecs // 36)
container['Date'] = time.strftime(
'%a, %d %b %Y %H:%M:%S',
time.localtime(now)) + tzoffset
Modified: python/branches/release26-maint/Lib/email/test/test_email_renamed.py
==============================================================================
--- python/branches/release26-maint/Lib/email/test/test_email_renamed.py (original)
+++ python/branches/release26-maint/Lib/email/test/test_email_renamed.py Mon Aug 2 20:40:55 2010
@@ -1044,7 +1044,7 @@
sign = '-'
else:
sign = '+'
- tzoffset = ' %s%04d' % (sign, tzsecs / 36)
+ tzoffset = ' %s%04d' % (sign, tzsecs // 36)
container['Date'] = time.strftime(
'%a, %d %b %Y %H:%M:%S',
time.localtime(now)) + tzoffset
Modified: python/branches/release26-maint/Lib/sqlite3/test/types.py
==============================================================================
--- python/branches/release26-maint/Lib/sqlite3/test/types.py (original)
+++ python/branches/release26-maint/Lib/sqlite3/test/types.py Mon Aug 2 20:40:55 2010
@@ -226,7 +226,7 @@
sqlite.converters["FOO"] = lambda x: "[%s]" % x
sqlite.converters["BAR"] = lambda x: "<%s>" % x
- sqlite.converters["EXC"] = lambda x: 5/0
+ sqlite.converters["EXC"] = lambda x: 5 // 0
sqlite.converters["B1B1"] = lambda x: "MARKER"
def tearDown(self):
Modified: python/branches/release26-maint/Lib/sqlite3/test/userfunctions.py
==============================================================================
--- python/branches/release26-maint/Lib/sqlite3/test/userfunctions.py (original)
+++ python/branches/release26-maint/Lib/sqlite3/test/userfunctions.py Mon Aug 2 20:40:55 2010
@@ -38,7 +38,7 @@
def func_returnblob():
return buffer("blob")
def func_raiseexception():
- 5/0
+ 5 // 0
def func_isstring(v):
return type(v) is unicode
@@ -67,7 +67,7 @@
class AggrExceptionInInit:
def __init__(self):
- 5/0
+ 5 // 0
def step(self, x):
pass
@@ -80,7 +80,7 @@
pass
def step(self, x):
- 5/0
+ 5 // 0
def finalize(self):
return 42
@@ -93,7 +93,7 @@
pass
def finalize(self):
- 5/0
+ 5 // 0
class AggrCheckType:
def __init__(self):
Modified: python/branches/release26-maint/Lib/test/infinite_reload.py
==============================================================================
--- python/branches/release26-maint/Lib/test/infinite_reload.py (original)
+++ python/branches/release26-maint/Lib/test/infinite_reload.py Mon Aug 2 20:40:55 2010
@@ -3,5 +3,6 @@
# reload()ing. This module is imported by test_import.py:test_infinite_reload
# to make sure this doesn't happen any more.
+import imp
import infinite_reload
-reload(infinite_reload)
+imp.reload(infinite_reload)
Modified: python/branches/release26-maint/Lib/test/inspect_fodder.py
==============================================================================
--- python/branches/release26-maint/Lib/test/inspect_fodder.py (original)
+++ python/branches/release26-maint/Lib/test/inspect_fodder.py Mon Aug 2 20:40:55 2010
@@ -15,7 +15,7 @@
fr = inspect.currentframe()
st = inspect.stack()
p = x
- q = y / 0
+ q = y // 0
# line 20
class StupidGit:
Modified: python/branches/release26-maint/Lib/test/regrtest.py
==============================================================================
--- python/branches/release26-maint/Lib/test/regrtest.py (original)
+++ python/branches/release26-maint/Lib/test/regrtest.py Mon Aug 2 20:40:55 2010
@@ -133,6 +133,7 @@
# keep a reference to the ascii module to workaround #7140 bug
# (see issue #7027)
import encodings.ascii
+import imp
# I see no other way to suppress these warnings;
# putting them in test_grammar.py has no effect:
@@ -657,7 +658,7 @@
indirect_test()
else:
def run_the_test():
- reload(the_module)
+ imp.reload(the_module)
deltas = []
nwarmup, ntracked, fname = huntrleaks
Modified: python/branches/release26-maint/Lib/test/test_binop.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_binop.py (original)
+++ python/branches/release26-maint/Lib/test/test_binop.py Mon Aug 2 20:40:55 2010
@@ -207,6 +207,9 @@
"""Compare two Rats for inequality."""
return not self == other
+ # Silence Py3k warning
+ __hash__ = None
+
class RatTestCase(unittest.TestCase):
"""Unit tests for Rat class and its support utilities."""
Modified: python/branches/release26-maint/Lib/test/test_compiler.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_compiler.py (original)
+++ python/branches/release26-maint/Lib/test/test_compiler.py Mon Aug 2 20:40:55 2010
@@ -75,7 +75,7 @@
def testTryExceptFinally(self):
# Test that except and finally clauses in one try stmt are recognized
- c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1",
+ c = compiler.compile("try:\n 1//0\nexcept:\n e = 1\nfinally:\n f = 1",
"<string>", "exec")
dct = {}
exec c in dct
Modified: python/branches/release26-maint/Lib/test/test_descrtut.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_descrtut.py (original)
+++ python/branches/release26-maint/Lib/test/test_descrtut.py Mon Aug 2 20:40:55 2010
@@ -66,7 +66,7 @@
statement or the built-in function eval():
>>> def sorted(seq):
- ... seq.sort()
+ ... seq.sort(key=str)
... return seq
>>> print sorted(a.keys())
[1, 2]
Modified: python/branches/release26-maint/Lib/test/test_dict.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_dict.py (original)
+++ python/branches/release26-maint/Lib/test/test_dict.py Mon Aug 2 20:40:55 2010
@@ -582,11 +582,14 @@
type2test = Dict
def test_main():
- test_support.run_unittest(
- DictTest,
- GeneralMappingTests,
- SubclassMappingTests,
- )
+ with test_support._check_py3k_warnings(
+ ('dict(.has_key..| inequality comparisons) not supported in 3.x',
+ DeprecationWarning)):
+ test_support.run_unittest(
+ DictTest,
+ GeneralMappingTests,
+ SubclassMappingTests,
+ )
if __name__ == "__main__":
test_main()
Modified: python/branches/release26-maint/Lib/test/test_file.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_file.py (original)
+++ python/branches/release26-maint/Lib/test/test_file.py Mon Aug 2 20:40:55 2010
@@ -118,7 +118,7 @@
self.assertEquals(self.f.__exit__(None, None, None), None)
# it must also return None if an exception was given
try:
- 1/0
+ 1 // 0
except:
self.assertEquals(self.f.__exit__(*sys.exc_info()), None)
Modified: python/branches/release26-maint/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_ftplib.py (original)
+++ python/branches/release26-maint/Lib/test/test_ftplib.py Mon Aug 2 20:40:55 2010
@@ -90,7 +90,8 @@
sock.listen(5)
sock.settimeout(2)
ip, port = sock.getsockname()[:2]
- ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256
+ ip = ip.replace('.', ',')
+ p1, p2 = divmod(port, 256)
self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
conn, addr = sock.accept()
self.dtp = DummyDTPHandler(conn, baseclass=self)
Modified: python/branches/release26-maint/Lib/test/test_functools.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_functools.py (original)
+++ python/branches/release26-maint/Lib/test/test_functools.py Mon Aug 2 20:40:55 2010
@@ -119,7 +119,7 @@
def test_error_propagation(self):
def f(x, y):
- x / y
+ x // y
self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0))
self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0)
self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
Modified: python/branches/release26-maint/Lib/test/test_grammar.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_grammar.py (original)
+++ python/branches/release26-maint/Lib/test/test_grammar.py Mon Aug 2 20:40:55 2010
@@ -8,7 +8,8 @@
# regression test, the filterwarnings() call has been added to
# regrtest.py.
-from test.test_support import run_unittest, check_syntax_error
+from test.test_support import (run_unittest, check_syntax_error,
+ _check_py3k_warnings)
import unittest
import sys
# testing import *
@@ -152,8 +153,9 @@
f1(*(), **{})
def f2(one_argument): pass
def f3(two, arguments): pass
- def f4(two, (compound, (argument, list))): pass
- def f5((compound, first), two): pass
+ # Silence Py3k warning
+ exec('def f4(two, (compound, (argument, list))): pass')
+ exec('def f5((compound, first), two): pass')
self.assertEquals(f2.func_code.co_varnames, ('one_argument',))
self.assertEquals(f3.func_code.co_varnames, ('two', 'arguments'))
if sys.platform.startswith('java'):
@@ -172,7 +174,8 @@
def v0(*rest): pass
def v1(a, *rest): pass
def v2(a, b, *rest): pass
- def v3(a, (b, c), *rest): return a, b, c, rest
+ # Silence Py3k warning
+ exec('def v3(a, (b, c), *rest): return a, b, c, rest')
f1()
f2(1)
@@ -277,9 +280,10 @@
d22v(*(1, 2, 3, 4))
d22v(1, 2, *(3, 4, 5))
d22v(1, *(2, 3), **{'d': 4})
- def d31v((x)): pass
+ # Silence Py3k warning
+ exec('def d31v((x)): pass')
+ exec('def d32v((x,)): pass')
d31v(1)
- def d32v((x,)): pass
d32v((1,))
# keyword arguments after *arglist
@@ -474,7 +478,7 @@
continue
except:
raise
- if count > 2 or big_hippo <> 1:
+ if count > 2 or big_hippo != 1:
self.fail("continue then break in try/except in loop broken!")
test_inner()
@@ -536,7 +540,7 @@
if z != 2: self.fail('exec u\'z=1+1\'')"""
g = {}
exec 'z = 1' in g
- if g.has_key('__builtins__'): del g['__builtins__']
+ if '__builtins__' in g: del g['__builtins__']
if g != {'z': 1}: self.fail('exec \'z = 1\' in g')
g = {}
l = {}
@@ -544,8 +548,8 @@
import warnings
warnings.filterwarnings("ignore", "global statement", module="<string>")
exec 'global a; a = 1; b = 2' in g, l
- if g.has_key('__builtins__'): del g['__builtins__']
- if l.has_key('__builtins__'): del l['__builtins__']
+ if '__builtins__' in g: del g['__builtins__']
+ if '__builtins__' in l: del l['__builtins__']
if (g, l) != ({'a':1}, {'b':2}):
self.fail('exec ... in g (%s), l (%s)' %(g,l))
@@ -677,7 +681,6 @@
x = (1 == 1)
if 1 == 1: pass
if 1 != 1: pass
- if 1 <> 1: pass
if 1 < 1: pass
if 1 > 1: pass
if 1 <= 1: pass
@@ -686,7 +689,10 @@
if 1 is not 1: pass
if 1 in (): pass
if 1 not in (): pass
- if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass
+ if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
+ # Silence Py3k warning
+ if eval('1 <> 1'): pass
+ if eval('1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1'): pass
def testBinaryMaskOps(self):
x = 1 & 1
@@ -769,9 +775,10 @@
x = {'one': 1, 'two': 2,}
x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6}
- x = `x`
- x = `1 or 2 or 3`
- self.assertEqual(`1,2`, '(1, 2)')
+ # Silence Py3k warning
+ x = eval('`x`')
+ x = eval('`1 or 2 or 3`')
+ self.assertEqual(eval('`1,2`'), '(1, 2)')
x = x
x = 'x'
@@ -948,7 +955,13 @@
def test_main():
- run_unittest(TokenTests, GrammarTests)
+ with _check_py3k_warnings(
+ ("backquote not supported", SyntaxWarning),
+ ("tuple parameter unpacking has been removed", SyntaxWarning),
+ ("parenthesized argument names are invalid", SyntaxWarning),
+ ("classic int division", DeprecationWarning),
+ (".+ not supported in 3.x", DeprecationWarning)):
+ run_unittest(TokenTests, GrammarTests)
if __name__ == '__main__':
test_main()
Modified: python/branches/release26-maint/Lib/test/test_import.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_import.py (original)
+++ python/branches/release26-maint/Lib/test/test_import.py Mon Aug 2 20:40:55 2010
@@ -7,6 +7,7 @@
import py_compile
import warnings
import marshal
+import imp
from test.test_support import (unlink, TESTFN, unload, run_unittest,
check_warnings, TestFailed)
@@ -56,11 +57,10 @@
f.close()
try:
- try:
- mod = __import__(TESTFN)
- except ImportError, err:
- self.fail("import from %s failed: %s" % (ext, err))
-
+ mod = __import__(TESTFN)
+ except ImportError, err:
+ self.fail("import from %s failed: %s" % (ext, err))
+ else:
self.assertEquals(mod.a, a,
"module loaded (%s) but contents invalid" % mod)
self.assertEquals(mod.b, b,
@@ -69,10 +69,9 @@
os.unlink(source)
try:
- try:
- reload(mod)
- except ImportError, err:
- self.fail("import from .pyc/.pyo failed: %s" % err)
+ imp.reload(mod)
+ except ImportError, err:
+ self.fail("import from .pyc/.pyo failed: %s" % err)
finally:
try:
os.unlink(pyc)
@@ -159,7 +158,7 @@
def test_failing_import_sticks(self):
source = TESTFN + os.extsep + "py"
f = open(source, "w")
- print >> f, "a = 1/0"
+ print >> f, "a = 1 // 0"
f.close()
# New in 2.4, we shouldn't be able to import that no matter how often
@@ -205,7 +204,7 @@
print >> f, "b = 20//0"
f.close()
- self.assertRaises(ZeroDivisionError, reload, mod)
+ self.assertRaises(ZeroDivisionError, imp.reload, mod)
# But we still expect the module to be in sys.modules.
mod = sys.modules.get(TESTFN)
Modified: python/branches/release26-maint/Lib/test/test_importhooks.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_importhooks.py (original)
+++ python/branches/release26-maint/Lib/test/test_importhooks.py Mon Aug 2 20:40:55 2010
@@ -180,7 +180,7 @@
self.failIf(hasattr(reloadmodule,'reloaded'))
TestImporter.modules['reloadmodule'] = (False, reload_co)
- reload(reloadmodule)
+ imp.reload(reloadmodule)
self.failUnless(hasattr(reloadmodule,'reloaded'))
import hooktestpackage.oldabs
@@ -247,9 +247,10 @@
for n in sys.modules.keys():
if n.startswith(parent):
del sys.modules[n]
- for mname in mnames:
- m = __import__(mname, globals(), locals(), ["__dummy__"])
- m.__loader__ # to make sure we actually handled the import
+ with test_support._check_py3k_warnings():
+ for mname in mnames:
+ m = __import__(mname, globals(), locals(), ["__dummy__"])
+ m.__loader__ # to make sure we actually handled the import
def test_main():
Modified: python/branches/release26-maint/Lib/test/test_inspect.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_inspect.py (original)
+++ python/branches/release26-maint/Lib/test/test_inspect.py Mon Aug 2 20:40:55 2010
@@ -119,7 +119,7 @@
self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam',
[' eggs(b + d, c + f)\n'], 0))
self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs',
- [' q = y / 0\n'], 0))
+ [' q = y // 0\n'], 0))
def test_frame(self):
args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
Modified: python/branches/release26-maint/Lib/test/test_io.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_io.py (original)
+++ python/branches/release26-maint/Lib/test/test_io.py Mon Aug 2 20:40:55 2010
@@ -248,11 +248,11 @@
f = None
try:
with open(test_support.TESTFN, "wb", bufsize) as f:
- 1/0
+ 1 // 0
except ZeroDivisionError:
self.assertEqual(f.closed, True)
else:
- self.fail("1/0 didn't raise an exception")
+ self.fail("1 // 0 didn't raise an exception")
# issue 5008
def test_append_mode_tell(self):
Modified: python/branches/release26-maint/Lib/test/test_itertools.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_itertools.py (original)
+++ python/branches/release26-maint/Lib/test/test_itertools.py Mon Aug 2 20:40:55 2010
@@ -7,6 +7,7 @@
import random
import copy
import pickle
+from functools import reduce
maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1
@@ -112,7 +113,7 @@
values = [5*x-12 for x in range(n)]
for r in range(n+2):
result = list(combinations(values, r))
- self.assertEqual(len(result), 0 if r>n else fact(n) / fact(r) / fact(n-r)) # right number of combs
+ self.assertEqual(len(result), 0 if r>n else fact(n) // fact(r) // fact(n-r)) # right number of combs
self.assertEqual(len(result), len(set(result))) # no repeats
self.assertEqual(result, sorted(result)) # lexicographic order
for c in result:
@@ -176,7 +177,7 @@
values = [5*x-12 for x in range(n)]
for r in range(n+2):
result = list(permutations(values, r))
- self.assertEqual(len(result), 0 if r>n else fact(n) / fact(n-r)) # right number of perms
+ self.assertEqual(len(result), 0 if r>n else fact(n) // fact(n-r)) # right number of perms
self.assertEqual(len(result), len(set(result))) # no repeats
self.assertEqual(result, sorted(result)) # lexicographic order
for p in result:
@@ -370,7 +371,10 @@
[range(1000), range(0), range(3000,3050), range(1200), range(1500)],
[range(1000), range(0), range(3000,3050), range(1200), range(1500), range(0)],
]:
- target = map(None, *args)
+ # target = map(None, *args) <- this raises a py3k warning
+ # this is the replacement:
+ target = [tuple([arg[i] if i < len(arg) else None for arg in args])
+ for i in range(max(map(len, args)))]
self.assertEqual(list(izip_longest(*args)), target)
self.assertEqual(list(izip_longest(*args, **{})), target)
target = [tuple((e is None and 'X' or e) for e in t) for t in target] # Replace None fills with 'X'
@@ -382,7 +386,8 @@
self.assertEqual(list(izip_longest([])), zip([]))
self.assertEqual(list(izip_longest('abcdef')), zip('abcdef'))
- self.assertEqual(list(izip_longest('abc', 'defg', **{})), map(None, 'abc', 'defg')) # empty keyword dict
+ self.assertEqual(list(izip_longest('abc', 'defg', **{})),
+ zip(list('abc') + [None], 'defg')) # empty keyword dict
self.assertRaises(TypeError, izip_longest, 3)
self.assertRaises(TypeError, izip_longest, range(3), 3)
@@ -1228,7 +1233,7 @@
# is differencing with a range so that consecutive numbers all appear in
# same group.
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
->>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
+>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]):
... print map(operator.itemgetter(1), g)
...
[1]
Modified: python/branches/release26-maint/Lib/test/test_mutants.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_mutants.py (original)
+++ python/branches/release26-maint/Lib/test/test_mutants.py Mon Aug 2 20:40:55 2010
@@ -210,7 +210,7 @@
# Tim sez: "luck of the draw; crashes with or without for me."
print >> f
- return `"machiavelli"`
+ return repr("machiavelli")
def __hash__(self):
return 0
Modified: python/branches/release26-maint/Lib/test/test_opcodes.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_opcodes.py (original)
+++ python/branches/release26-maint/Lib/test/test_opcodes.py Mon Aug 2 20:40:55 2010
@@ -1,6 +1,6 @@
# Python test set -- part 2, opcodes
-from test.test_support import run_unittest
+from test.test_support import run_unittest, _check_py3k_warnings
import unittest
class OpcodeTest(unittest.TestCase):
@@ -9,7 +9,7 @@
n = 0
for i in range(10):
n = n+i
- try: 1/0
+ try: 1 // 0
except NameError: pass
except ZeroDivisionError: pass
except TypeError: pass
@@ -104,7 +104,12 @@
def test_main():
- run_unittest(OpcodeTest)
+ with _check_py3k_warnings(("exceptions must derive from BaseException",
+ DeprecationWarning),
+ ("catching classes that don't inherit "
+ "from BaseException is not allowed",
+ DeprecationWarning)):
+ run_unittest(OpcodeTest)
if __name__ == '__main__':
test_main()
Modified: python/branches/release26-maint/Lib/test/test_optparse.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_optparse.py (original)
+++ python/branches/release26-maint/Lib/test/test_optparse.py Mon Aug 2 20:40:55 2010
@@ -26,12 +26,6 @@
from optparse import _match_abbrev
from optparse import _parse_num
-# Do the right thing with boolean values for all known Python versions.
-try:
- True, False
-except NameError:
- (True, False) = (1, 0)
-
retype = type(re.compile(''))
class InterceptedError(Exception):
Modified: python/branches/release26-maint/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_ossaudiodev.py (original)
+++ python/branches/release26-maint/Lib/test/test_ossaudiodev.py Mon Aug 2 20:40:55 2010
@@ -44,7 +44,8 @@
try:
dsp = ossaudiodev.open('w')
except IOError, msg:
- if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
+ if msg.args[0] in (errno.EACCES, errno.ENOENT,
+ errno.ENODEV, errno.EBUSY):
raise TestSkipped(msg)
raise
@@ -70,7 +71,7 @@
self.fail("dsp.%s not read-only" % attr)
# Compute expected running time of sound sample (in seconds).
- expected_time = float(len(data)) / (ssize/8) / nchannels / rate
+ expected_time = float(len(data)) / (ssize//8) / nchannels / rate
# set parameters based on .au file headers
dsp.setparameters(AFMT_S16_NE, nchannels, rate)
@@ -161,7 +162,8 @@
try:
dsp = ossaudiodev.open('w')
except (ossaudiodev.error, IOError), msg:
- if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
+ if msg.args[0] in (errno.EACCES, errno.ENOENT,
+ errno.ENODEV, errno.EBUSY):
raise TestSkipped(msg)
raise
dsp.close()
Modified: python/branches/release26-maint/Lib/test/test_pkgimport.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_pkgimport.py (original)
+++ python/branches/release26-maint/Lib/test/test_pkgimport.py Mon Aug 2 20:40:55 2010
@@ -6,14 +6,14 @@
def __init__(self, *args, **kw):
self.package_name = 'PACKAGE_'
- while sys.modules.has_key(self.package_name):
+ while self.package_name in sys.modules:
self.package_name += random.choose(string.letters)
self.module_name = self.package_name + '.foo'
unittest.TestCase.__init__(self, *args, **kw)
def remove_modules(self):
for module_name in (self.package_name, self.module_name):
- if sys.modules.has_key(module_name):
+ if module_name in sys.modules:
del sys.modules[module_name]
def setUp(self):
@@ -52,8 +52,8 @@
try: __import__(self.module_name)
except SyntaxError: pass
else: raise RuntimeError, 'Failed to induce SyntaxError'
- self.assert_(not sys.modules.has_key(self.module_name) and
- not hasattr(sys.modules[self.package_name], 'foo'))
+ self.assertTrue(self.module_name not in sys.modules)
+ self.assertFalse(hasattr(sys.modules[self.package_name], 'foo'))
# ...make up a variable name that isn't bound in __builtins__
var = 'a'
Modified: python/branches/release26-maint/Lib/test/test_pyexpat.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_pyexpat.py (original)
+++ python/branches/release26-maint/Lib/test/test_pyexpat.py Mon Aug 2 20:40:55 2010
@@ -554,7 +554,7 @@
self.n=0
parser.Parse(xml1, 0)
- parser.buffer_size /= 2
+ parser.buffer_size //= 2
self.assertEquals(parser.buffer_size, 1024)
parser.Parse(xml2, 1)
self.assertEquals(self.n, 4)
Modified: python/branches/release26-maint/Lib/test/test_queue.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_queue.py (original)
+++ python/branches/release26-maint/Lib/test/test_queue.py Mon Aug 2 20:40:55 2010
@@ -102,21 +102,23 @@
q.put(i)
self.assert_(not q.empty(), "Queue should not be empty")
self.assert_(not q.full(), "Queue should not be full")
- q.put("last")
+ last = 2 * QUEUE_SIZE
+ full = 3 * 2 * QUEUE_SIZE
+ q.put(last)
self.assert_(q.full(), "Queue should be full")
try:
- q.put("full", block=0)
+ q.put(full, block=0)
self.fail("Didn't appear to block with a full queue")
except Queue.Full:
pass
try:
- q.put("full", timeout=0.01)
+ q.put(full, timeout=0.01)
self.fail("Didn't appear to time-out with a full queue")
except Queue.Full:
pass
# Test a blocking put
- self.do_blocking_test(q.put, ("full",), q.get, ())
- self.do_blocking_test(q.put, ("full", True, 10), q.get, ())
+ self.do_blocking_test(q.put, (full,), q.get, ())
+ self.do_blocking_test(q.put, (full, True, 10), q.get, ())
# Empty it
for i in range(QUEUE_SIZE):
q.get()
Modified: python/branches/release26-maint/Lib/test/test_random.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_random.py (original)
+++ python/branches/release26-maint/Lib/test/test_random.py Mon Aug 2 20:40:55 2010
@@ -6,6 +6,7 @@
import pickle
import warnings
from math import log, exp, sqrt, pi, fsum as msum
+from functools import reduce
from test import test_support
class TestBasicOps(unittest.TestCase):
Modified: python/branches/release26-maint/Lib/test/test_repr.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_repr.py (original)
+++ python/branches/release26-maint/Lib/test/test_repr.py Mon Aug 2 20:40:55 2010
@@ -8,7 +8,7 @@
import shutil
import unittest
-from test.test_support import run_unittest
+from test.test_support import run_unittest, _check_py3k_warnings
from repr import repr as r # Don't shadow builtin repr
from repr import Repr
@@ -174,7 +174,8 @@
def test_buffer(self):
# XXX doesn't test buffers with no b_base or read-write buffers (see
# bufferobject.c). The test is fairly incomplete too. Sigh.
- x = buffer('foo')
+ with _check_py3k_warnings():
+ x = buffer('foo')
self.failUnless(repr(x).startswith('<read-only buffer for 0x'))
def test_cell(self):
Modified: python/branches/release26-maint/Lib/test/test_rfc822.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_rfc822.py (original)
+++ python/branches/release26-maint/Lib/test/test_rfc822.py Mon Aug 2 20:40:55 2010
@@ -46,9 +46,9 @@
continue
i = i + 1
self.assertEqual(mn, n,
- "Un-expected name: %s != %s" % (`mn`, `n`))
+ "Un-expected name: %r != %r" % (mn, n))
self.assertEqual(ma, a,
- "Un-expected address: %s != %s" % (`ma`, `a`))
+ "Un-expected address: %r != %r" % (ma, a))
if mn == n and ma == a:
pass
else:
Modified: python/branches/release26-maint/Lib/test/test_site.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_site.py (original)
+++ python/branches/release26-maint/Lib/test/test_site.py Mon Aug 2 20:40:55 2010
@@ -196,7 +196,7 @@
site.abs__file__()
for module in (sys, os, __builtin__):
try:
- self.failUnless(os.path.isabs(module.__file__), `module`)
+ self.assertTrue(os.path.isabs(module.__file__), repr(module))
except AttributeError:
continue
# We could try everything in sys.modules; however, when regrtest.py
@@ -248,7 +248,7 @@
def test_sitecustomize_executed(self):
# If sitecustomize is available, it should have been imported.
- if not sys.modules.has_key("sitecustomize"):
+ if "sitecustomize" not in sys.modules:
try:
import sitecustomize
except ImportError:
Modified: python/branches/release26-maint/Lib/test/test_sys.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_sys.py (original)
+++ python/branches/release26-maint/Lib/test/test_sys.py Mon Aug 2 20:40:55 2010
@@ -75,7 +75,8 @@
self.assert_(value is exc)
self.assert_(traceback is not None)
- sys.exc_clear()
+ with test.test_support._check_py3k_warnings():
+ sys.exc_clear()
typ, value, traceback = sys.exc_info()
self.assert_(typ is None)
@@ -498,7 +499,8 @@
# bool
check(True, size(h + 'l'))
# buffer
- check(buffer(''), size(h + '2P2Pil'))
+ with test.test_support._check_py3k_warnings():
+ check(buffer(''), size(h + '2P2Pil'))
# builtin_function_or_method
check(len, size(h + '3P'))
# bytearray
Modified: python/branches/release26-maint/Lib/test/test_threadsignals.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_threadsignals.py (original)
+++ python/branches/release26-maint/Lib/test/test_threadsignals.py Mon Aug 2 20:40:55 2010
@@ -14,7 +14,7 @@
signalled_all=thread.allocate_lock()
-def registerSignals((for_usr1, for_usr2, for_alrm)):
+def registerSignals(for_usr1, for_usr2, for_alrm):
usr1 = signal.signal(signal.SIGUSR1, for_usr1)
usr2 = signal.signal(signal.SIGUSR2, for_usr2)
alrm = signal.signal(signal.SIGALRM, for_alrm)
@@ -74,11 +74,11 @@
signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 },
signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } }
- oldsigs = registerSignals((handle_signals, handle_signals, handle_signals))
+ oldsigs = registerSignals(handle_signals, handle_signals, handle_signals)
try:
run_unittest(ThreadSignals)
finally:
- registerSignals(oldsigs)
+ registerSignals(*oldsigs)
if __name__ == '__main__':
test_main()
Modified: python/branches/release26-maint/Lib/test/test_trace.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_trace.py (original)
+++ python/branches/release26-maint/Lib/test/test_trace.py Mon Aug 2 20:40:55 2010
@@ -401,7 +401,7 @@
we're testing, so that the 'exception' trace event fires."""
if self.raiseOnEvent == 'exception':
x = 0
- y = 1/x
+ y = 1 // x
else:
return 1
Modified: python/branches/release26-maint/Lib/test/test_traceback.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_traceback.py (original)
+++ python/branches/release26-maint/Lib/test/test_traceback.py Mon Aug 2 20:40:55 2010
@@ -4,6 +4,7 @@
from StringIO import StringIO
import sys
import unittest
+from imp import reload
from test.test_support import run_unittest, is_jython, Error
import traceback
@@ -158,7 +159,7 @@
def test_format_exception_only_bad__str__(self):
class X(Exception):
def __str__(self):
- 1/0
+ 1 // 0
err = traceback.format_exception_only(X, X())
self.assertEqual(len(err), 1)
str_value = '<unprintable %s object>' % X.__name__
Modified: python/branches/release26-maint/Lib/test/test_with.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_with.py (original)
+++ python/branches/release26-maint/Lib/test/test_with.py Mon Aug 2 20:40:55 2010
@@ -529,7 +529,7 @@
self.assertRaises(AssertionError, falseAsBool)
def failAsBool():
- with cm(lambda: 1//0):
+ with cm(lambda: 1 // 0):
self.fail("Should NOT see this")
self.assertRaises(ZeroDivisionError, failAsBool)
@@ -637,7 +637,7 @@
def __exit__(self, t, v, tb): return True
try:
with AfricanSwallow():
- 1/0
+ 1 // 0
except ZeroDivisionError:
self.fail("ZeroDivisionError should have been swallowed")
@@ -647,7 +647,7 @@
def __exit__(self, t, v, tb): return False
try:
with EuropeanSwallow():
- 1/0
+ 1 // 0
except ZeroDivisionError:
pass
else:
Modified: python/branches/release26-maint/Lib/test/test_wsgiref.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_wsgiref.py (original)
+++ python/branches/release26-maint/Lib/test/test_wsgiref.py Mon Aug 2 20:40:55 2010
@@ -432,10 +432,10 @@
env = handler.environ
from os import environ
for k,v in environ.items():
- if not empty.has_key(k):
+ if k not in empty:
self.assertEqual(env[k],v)
for k,v in empty.items():
- self.failUnless(env.has_key(k))
+ self.assertTrue(k in env)
def testEnviron(self):
h = TestHandler(X="Y")
@@ -448,7 +448,7 @@
h = BaseCGIHandler(None,None,None,{})
h.setup_environ()
for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
- self.assert_(h.environ.has_key(key))
+ self.assertTrue(key in h.environ)
def testScheme(self):
h=TestHandler(HTTPS="on"); h.setup_environ()
Modified: python/branches/release26-maint/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_xml_etree.py (original)
+++ python/branches/release26-maint/Lib/test/test_xml_etree.py Mon Aug 2 20:40:55 2010
@@ -37,7 +37,7 @@
"""
def check_method(method):
- if not callable(method):
+ if not hasattr(method, '__call__'):
print method, "not callable"
def serialize(ET, elem, encoding=None):
Modified: python/branches/release26-maint/Lib/test/test_xml_etree_c.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_xml_etree_c.py (original)
+++ python/branches/release26-maint/Lib/test/test_xml_etree_c.py Mon Aug 2 20:40:55 2010
@@ -35,7 +35,7 @@
"""
def check_method(method):
- if not callable(method):
+ if not hasattr(method, '__call__'):
print method, "not callable"
def serialize(ET, elem, encoding=None):
More information about the Python-checkins
mailing list