This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients belopolsky, brian.curtin, loewis, max-alleged, ncoghlan, ocean-city, terry.reedy
Date 2012-07-26.01:09:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343264980.5.0.914166010784.issue10654@psf.upfronthosting.co.za>
In-reply-to
Content
I do not see the error with installed 3.2.3. I **DO** see it consistently, when running the test with installed 3.3.0b1 on 64 bit Win 7. The only failure is
======================================================================
FAIL: test_computations (test.datetimetester.TestSubclassDateTime_Fast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Programs\Python33\lib\test\datetimetester.py", line 1640, in test_computations
    self.assertRaises(TypeError, lambda: a+i)
AssertionError: TypeError not raised by <lambda>
ionError: TypeError not raised by <lambda>

The other 9 runs of test_computations pass.
test_computations (test.datetimetester.TestDate_Pure) ... ok
test_computations (test.datetimetester.TestDateTimeTZ_Pure) ... ok
test_computations (test.datetimetester.TestTimeDelta_Pure) ... ok
test_computations (test.datetimetester.TestSubclassDateTime_Pure) ... ok
test_computations (test.datetimetester.TestDateTime_Pure) ... ok
test_computations (test.datetimetester.TestDate_Fast) ... ok
test_computations (test.datetimetester.TestDateTimeTZ_Fast) ... ok
test_computations (test.datetimetester.TestTimeDelta_Fast) ... ok
test_computations (test.datetimetester.TestDateTime_Fast) ... ok

I reproduce in same way Hirokazo does.
>>> class Sub(datetime): pass

>>> dsub = Sub(2002, 1, 31)
>>> dsub+1
NotImplemented
>>> d = datetime(2000,1,1)
>>> d+1
Traceback (most recent call last):
  File "<pyshell#28>", line 1, in <module>
    b+1
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'int'

My understanding of a+b is that a.__add__(b) is tried and if it NotImplemented, which d and dsub.__add__(1) do, b.__radd__(a) is tried. If that does the same, TypeError is raised. 1 .__radd__(x) returns NotImplemented for both d and dsub, but TypeError is raised only for d, not dsub.

Alexander, there are known problems with abstract.c #11477

Nick, I nosied you because you have worked on the binary op dance. Are there special problems for Python subclasses of builtins? Is this problem the same or related to the one in #11477?
History
Date User Action Args
2012-07-26 01:09:40terry.reedysetrecipients: + terry.reedy, loewis, ncoghlan, belopolsky, ocean-city, brian.curtin, max-alleged
2012-07-26 01:09:40terry.reedysetmessageid: <1343264980.5.0.914166010784.issue10654@psf.upfronthosting.co.za>
2012-07-26 01:09:39terry.reedylinkissue10654 messages
2012-07-26 01:09:39terry.reedycreate