[pypy-issue] [issue1662] 'is' should be '==' in datetime.py
Kevin Duffy
tracker at bugs.pypy.org
Wed Dec 18 01:37:13 CET 2013
Kevin Duffy <kmdext at apple.com> added the comment:
Right, they should pass on both interpreters. When I consulted the CPython 2.7.6 implementation in
Modules/datetimemodule.c, astimezone() does do a pointer comparison so I can remove my patch for astimezone(). If you look
at time_richcompare() and datetime_subtract() in CPython it does not have the equivalent of the PyPy tzinfo comparison (if
my.tzinfo is other.tzinfo) - it always calls utcoffset(). I still believe changing the 'is' to a '==' is more correct in
these cases. One reason is if you look at datetime.__cmp__ and time.__sub__ in PyPy, they use a '==' not an 'is'.
Since CPython doesn't do the exact equivalent code (tzinfo comparison), I'm not sure how to get the tests to fail on PyPy
without the patch AND succeed on CPython without doing an interpreter check. The difference between the interpreters is one
should call utcoffset and one shouldn't.
Attaching an updated patch that removes changes to astimezone and updated tests that at least pass on both interpreters.
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1662>
________________________________________
More information about the pypy-issue
mailing list