[pypy-commit] pypy default: Fix: apply this change, even if it's incompatible with CPython 2.2(!).

arigo noreply at buildbot.pypy.org
Mon Apr 2 17:21:51 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r54152:49d683bbd92b
Date: 2012-04-02 17:17 +0200
http://bitbucket.org/pypy/pypy/changeset/49d683bbd92b/

Log:	Fix: apply this change, even if it's incompatible with CPython
	2.2(!). It fixes an issue reported by adoven on irc. Add a test.

diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -968,8 +968,7 @@
             self._checkOverflow(t.year)
             result = date(t.year, t.month, t.day)
             return result
-        raise TypeError
-        # XXX Should be 'return NotImplemented', but there's a bug in 2.2...
+        return NotImplemented    # note that this doesn't work on CPython 2.2
 
     __radd__ = __add__
 
diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -44,3 +44,9 @@
     assert type(dt.microsecond) is int
 
     copy.copy(dt)
+
+def test_radd():
+    class X(object):
+        def __radd__(self, other):
+            return "radd"
+    assert datetime.date(10, 10, 10) + X() == "radd"


More information about the pypy-commit mailing list