[pypy-commit] pypy py3k-stdlib-2.7.6-merge: adapt to py3

pjenvey noreply at buildbot.pypy.org
Tue Mar 11 21:24:14 CET 2014


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k-stdlib-2.7.6-merge
Changeset: r69874:1480ca4330b0
Date: 2014-03-11 13:22 -0700
http://bitbucket.org/pypy/pypy/changeset/1480ca4330b0/

Log:	adapt to py3

diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py
--- a/pypy/module/__builtin__/test/test_functional.py
+++ b/pypy/module/__builtin__/test/test_functional.py
@@ -435,19 +435,19 @@
 
     def test_cpython_issue16029(self):
         import sys
-        M = min(sys.maxint, sys.maxsize)
-        x = xrange(0, M, M - 1)
-        assert x.__reduce__() == (xrange, (0, M, M - 1))
-        x = xrange(0, -M, 1 - M)
-        assert x.__reduce__() == (xrange, (0, -M - 1, 1 - M))
+        M = sys.maxsize
+        x = range(0, M, M - 1)
+        assert x.__reduce__() == (range, (0, M, M - 1))
+        x = range(0, -M, 1 - M)
+        assert x.__reduce__() == (range, (0, -M, 1 - M))
 
     def test_cpython_issue16030(self):
         import sys
-        M = min(sys.maxint, sys.maxsize)
-        x = xrange(0, M, M - 1)
-        assert repr(x) == 'xrange(0, %s, %s)' % (M, M - 1)
-        x = xrange(0, -M, 1 - M)
-        assert repr(x) == 'xrange(0, %s, %s)' % (-M - 1, 1 - M)
+        M = sys.maxsize
+        x = range(0, M, M - 1)
+        assert repr(x) == 'range(0, %s, %s)' % (M, M - 1), repr(x)
+        x = range(0, -M, 1 - M)
+        assert repr(x) == 'range(0, %s, %s)' % (-M, 1 - M), repr(x)
 
 
 class AppTestReversed:
diff --git a/pypy/module/_socket/interp_func.py b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -272,7 +272,7 @@
     # port can be None, int or string
     if space.is_w(w_port, space.w_None):
         port = None
-    elif space.isinstance_w(w_port, space.w_int) or space.isinstance_w(w_port, space.w_long):
+    elif space.isinstance_w(w_port, space.w_int):
         port = str(space.int_w(w_port))
     elif space.isinstance_w(w_port, space.w_bytes):
         port = space.bytes_w(w_port)
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -548,7 +548,9 @@
         try:
             w_value = maybe_int(space, w_value)
         except OperationError:
-            w_value = space.long(w_value)
+            raise oefmt(space.w_TypeError,
+                        "%s format: a number is required, not %T",
+                        fmt, w_value)
         try:
             value = space.int_w(w_value)
             return fmt % (value,)
diff --git a/pypy/objspace/std/test/test_stringformat.py b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -184,14 +184,14 @@
         x = MyInt(65)
         assert '%c' % x == 'A'
 
-    def test_format_retry_with_long_if_int_fails(self):
+    def test_int_fails(self):
         class IntFails(object):
             def __int__(self):
                 raise Exception
-            def __long__(self):
-                return 0L
 
-        assert "%x" % IntFails() == '0'
+        exc = raises(TypeError, "%x".__mod__, IntFails())
+        expected = "%x format: a number is required, not IntFails"
+        assert str(exc.value) == expected
 
     def test_formatting_huge_precision(self):
         prec = 2**31


More information about the pypy-commit mailing list