Issue1950
Created on 2012-07-25.00:57:36 by Arfrever, last changed 2015-03-20.18:43:03 by zyasoft.
msg7335 (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) |
Date: 2012-07-25.00:57:35 |
|
datetime.date.__add__() should return NotImplemented instead of raising TypeError, as is already mentioned in source code.
This change fixes errors in test suite of python-dateutil (http://pypi.python.org/pypi/python-dateutil).
--- Lib/datetime.py
+++ Lib/datetime.py
@@ -911,8 +911,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
__radd__ = __add__
|
msg7347 (view) |
Author: Frank Wierzbicki (fwierzbicki) |
Date: 2012-08-03.16:33:26 |
|
But, this is the behavior of CPython 2.7 (I think it is fixed in 3.3)
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import date
>>> x = date(1,2,3)
>>> y = date(4,5,6)
>>> x + y
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'datetime.date' and 'datetime.date'
|
msg7348 (view) |
Author: Frank Wierzbicki (fwierzbicki) |
Date: 2012-08-03.16:35:07 |
|
Marking this as deferred in hopes that we remember to fix this in 3.3.
|
msg7351 (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) |
Date: 2012-08-04.05:36:03 |
|
The suggested change in Lib/datetime.py is still correct, but apparently Jython incorrectly handles NotImplemented (issue #1955).
|
msg8497 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-05-21.23:10:10 |
|
Is dateutil using the datetime internals in some way?
Re support in 3.x, let's not use bugs here to remind us of that sort of functionality, hopefully it's in a unit test.
|
msg8563 (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) |
Date: 2014-05-22.10:32:01 |
|
python-dateutil defines class dateutil.relativedelta.relativedelta with __add__() method, which allows addition operation between instances of datetime.date and dateutil.relativedelta.relativedelta.
$ python2.7 -c 'import datetime, dateutil.relativedelta; print(datetime.date(2014, 5, 22) + dateutil.relativedelta.relativedelta(months=3))'
2014-08-22
$ jython2.7 -c 'import datetime, dateutil.relativedelta; print(datetime.date(2014, 5, 22) + dateutil.relativedelta.relativedelta(months=3))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/share/jython-2.7/Lib/datetime.py", line 925, in __add__
raise TypeError
TypeError
|
msg9685 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-03-20.18:42:35 |
|
Except for three exceptions re "This test fails if you don't have the dateutil timezone file installed", all dateutil tests now pass against https://github.com/dateutil/dateutil/
Duplicate of #2010. #1995 is not relevant since this update of datetime uses new style classes
Fixed by https://hg.python.org/jython/rev/daa6bf9a14d5
|
msg9686 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-03-20.18:43:03 |
|
Or rather, *no longer* relevant
|
|
Date |
User |
Action |
Args |
2015-03-20 18:43:03 | zyasoft | set | messages:
+ msg9686 |
2015-03-20 18:42:35 | zyasoft | set | status: open -> closed resolution: fixed messages:
+ msg9685 |
2014-05-22 10:32:02 | Arfrever | set | messages:
+ msg8563 |
2014-05-21 23:10:10 | zyasoft | set | nosy:
+ zyasoft messages:
+ msg8497 |
2013-02-19 18:46:14 | fwierzbicki | set | versions:
+ Jython 2.7, - Deferred |
2012-08-04 05:36:04 | Arfrever | set | messages:
+ msg7351 |
2012-08-03 16:35:08 | fwierzbicki | set | messages:
+ msg7348 versions:
+ Deferred |
2012-08-03 16:33:26 | fwierzbicki | set | messages:
+ msg7347 |
2012-07-25 00:57:36 | Arfrever | create | |
|