[pypy-svn] pypy default: On CPython, __oct__() is called if Foobar inherits from 'long',

arigo commits-noreply at bitbucket.org
Mon Feb 7 19:50:46 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41683:30f40ccba8de
Date: 2011-02-07 19:50 +0100
http://bitbucket.org/pypy/pypy/changeset/30f40ccba8de/

Log:	On CPython, __oct__() is called if Foobar inherits from 'long', but
	not, say, 'object' or 'int' or 'str'. This seems strange enough to
	consider it a complete implementation detail (or really a bug, if
	you prefer).

diff --git a/lib-python/modified-2.7.0/test/test_format.py b/lib-python/modified-2.7.0/test/test_format.py
--- a/lib-python/modified-2.7.0/test/test_format.py
+++ b/lib-python/modified-2.7.0/test/test_format.py
@@ -272,13 +272,16 @@
         test_exc(u'no format', u'1', TypeError,
                  "not all arguments converted during string formatting")
 
-        class Foobar(long):
-            def __oct__(self):
-                # Returning a non-string should not blow up.
-                return self + 1
-
-        test_exc('%o', Foobar(), TypeError,
-                 "expected string or Unicode object, long found")
+        if test_support.check_impl_detail():
+            # __oct__() is called if Foobar inherits from 'long', but
+            # not, say, 'object' or 'int' or 'str'.  This seems strange
+            # enough to consider it a complete implementation detail.
+            class Foobar(long):
+                def __oct__(self):
+                    # Returning a non-string should not blow up.
+                    return self + 1
+            test_exc('%o', Foobar(), TypeError,
+                     "expected string or Unicode object, long found")
 
         if maxsize == 2**31-1:
             # crashes 2.2.1 and earlier:


More information about the Pypy-commit mailing list