From 5312a7f912088361e2a1fccd5daeaa9dc4ff5fd3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 31 Jan 2015 11:27:06 +0200 Subject: [PATCH] Avoid deprecation warnings. --- 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 index fe0ed0a085f..1e882e37fb1 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -177,7 +177,7 @@ elif os.name == "posix": 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 index fb03758171d..4b137a5474e 100644 --- a/Lib/encodings/uu_codec.py +++ b/Lib/encodings/uu_codec.py @@ -84,7 +84,7 @@ def uu_decode(input,errors='strict'): 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 index 9d62779faeb..0ac458f1e3a 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -2066,7 +2066,7 @@ order (MRO) for bases """ "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 index dc02cb375e0..b9500318792 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -92,7 +92,7 @@ class ExceptionTests(unittest.TestCase): 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", '', 'exec') + #try: compile("try:\n\t1.0/0.0\n \t1.0/0.0\nfinally:\n pass\n", '', 'exec') #except TabError: pass #else: self.fail("TabError not raised") diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index f3da0b1ce96..6c342d8fdb3 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2954,7 +2954,7 @@ else: 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 index 00b8d197241..44f2c573536 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -797,7 +797,7 @@ class ThreadingExceptionTests(BaseTestCase): 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 @@ class ThreadingExceptionTests(BaseTestCase): 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 @@ class ThreadingExceptionTests(BaseTestCase): 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 index 7154217b1bb..a084b68b3f3 100644 --- a/Lib/test/test_timeit.py +++ b/Lib/test/test_timeit.py @@ -197,7 +197,7 @@ class TestTimeit(unittest.TestCase): def test_print_exc(self): s = StringIO() - t = timeit.Timer("1/0") + t = timeit.Timer("1.0/0.0") try: t.timeit() except: