[Python-checkins] cpython (2.7): Avoid deprecation warnings.

serhiy.storchaka python-checkins at python.org
Sat Jan 31 10:27:59 CET 2015


https://hg.python.org/cpython/rev/6ddcc1407ffa
changeset: 94407:6ddcc1407ffa
branch: 2.7
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Jan 31 11:27:06 2015 +0200
summary:
 Avoid deprecation warnings.
files:
 Lib/ctypes/util.py | 2 +-
 Lib/encodings/uu_codec.py | 2 +-
 Lib/test/test_descr.py | 2 +-
 Lib/test/test_exceptions.py | 2 +-
 Lib/test/test_ssl.py | 2 +-
 Lib/test/test_threading.py | 6 +++---
 Lib/test/test_timeit.py | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -177,7 +177,7 @@
 res = re.findall(expr, data)
 if not res:
 return _get_soname(_findLib_gcc(name))
- res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y)))
+ res.sort(key=_num_version)
 return res[-1]
 
 elif sys.platform == "sunos5":
diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py
--- a/Lib/encodings/uu_codec.py
+++ b/Lib/encodings/uu_codec.py
@@ -84,7 +84,7 @@
 data = a2b_uu(s)
 except binascii.Error, v:
 # Workaround for broken uuencoders by /Fredrik Lundh
- nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
+ nbytes = (((ord(s[0])-32) & 63) * 4 + 5) // 3
 data = a2b_uu(s[:nbytes])
 #sys.stderr.write("Warning: %s\n" % str(v))
 write(data)
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -2066,7 +2066,7 @@
 "attr on a property" % attr)
 
 class D(object):
- __getitem__ = property(lambda s: 1/0)
+ __getitem__ = property(lambda s: 1.0/0.0)
 
 d = D()
 try:
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -92,7 +92,7 @@
 
 self.raise_catch(TabError, "TabError")
 # can only be tested under -tt, and is the only test for -tt
- #try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n", '<string>', 'exec')
+ #try: compile("try:\n\t1.0/0.0\n \t1.0/0.0\nfinally:\n pass\n", '<string>', 'exec')
 #except TabError: pass
 #else: self.fail("TabError not raised")
 
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -2954,7 +2954,7 @@
 server_context, other_context, client_context = self.sni_contexts()
 
 def cb_raising(ssl_sock, server_name, initial_context):
- 1/0
+ 1.0/0.0
 server_context.set_servername_callback(cb_raising)
 
 with self.assertRaises(ssl.SSLError) as cm, \
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -797,7 +797,7 @@
 running = True
 while running:
 time.sleep(0.01)
- 1/0
+ 1.0/0.0
 t = threading.Thread(target=run)
 t.start()
 while not running:
@@ -824,7 +824,7 @@
 running = True
 while running:
 time.sleep(0.01)
- 1/0
+ 1.0/0.0
 t = threading.Thread(target=run)
 t.start()
 while not running:
@@ -852,7 +852,7 @@
 running = True
 while running:
 time.sleep(0.01)
- 1/0
+ 1.0/0.0
 sys.stderr = None
 t = threading.Thread(target=run)
 t.start()
diff --git a/Lib/test/test_timeit.py b/Lib/test/test_timeit.py
--- a/Lib/test/test_timeit.py
+++ b/Lib/test/test_timeit.py
@@ -197,7 +197,7 @@
 
 def test_print_exc(self):
 s = StringIO()
- t = timeit.Timer("1/0")
+ t = timeit.Timer("1.0/0.0")
 try:
 t.timeit()
 except:
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /