[pypy-dev] datetime module

David Fraser davidf at sjsoft.com
Fri Feb 4 10:04:04 CET 2005


David Fraser wrote:

> Hi
>
> I have been testing out pypy for the first time...
> I wanted to get the datetime module working and found that there was a 
> pure python implementation of it done before the C implementation, in 
> the nondist/sandbox/datetime module on Python CVS.
> This implementation works fairly well on pypy:
> - in order to test it, the attached patch to test_datetime is needed 
> to avoid problems with pickle and gc
> - other than pickling, the only test failures are below
> The datetime.py can be got directly here:
> http://cvs.sourceforge.net/viewcvs.py/*checkout*/python/python/nondist/sandbox/datetime/datetime.py?content-type=text%2Fplain&rev=1.160 
>
>
> ======================================================================
> FAIL: test_subclass_timedelta (__main__.TestTimeDelta)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "test_datetime.py", line 469, in test_subclass_timedelta
>    self.assert_(type(t3) is timedelta)
>  File 
> "/share/sjsoft/code/Python/pypy/dist-pypy/lib-python-2.3.4/unittest.py", 
> line 278, in failUnless
>    if not expr: raise self.failureException, msg
> AssertionError

This test fails in standard Python as well ... the basic problem is the 
datetime.py produced a derived type T when adding two T's together, the 
test expects it to produce a standard datetime.timedelta objects.
I've attached a patch (as plain text) that makes the result of 
arithmetic operations between datetime.timedelta objects standard 
datetime.timedelta objects. Not sure why this is a good thing, or if it 
should be done to the rest of the datetime code (its not tested for) - 
there are a few other places where self.__class__ is used to generate a 
derived result
With this patch and the classmodule patch all the non-pickle tests pass 
on my pypy.

David

PS this should check if text/x-patch mime types are now getting through 
to the list too.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: datetime-timedelta-fixedclass.patch
Type: text/x-patch
Size: 1479 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20050204/fe5ce3d9/attachment.bin>


More information about the Pypy-dev mailing list