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 ====================================================================== ERROR: test_combine (__main__.TestDateTime) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_datetime.py", line 1396, in test_combine dt = combine(time=t, date=d) TypeError: newfunc() got 2 unexpected keyword arguments ====================================================================== ERROR: test_more_astimezone (__main__.TestDateTimeTZ) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_datetime.py", line 2636, in test_more_astimezone dt = self.theclass.now(tz=f44m) TypeError: newfunc() got an unexpected keyword argument 'tz' ====================================================================== ERROR: test_tzinfo_fromtimestamp (__main__.TestDateTimeTZ) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_datetime.py", line 2423, in test_tzinfo_fromtimestamp again = meth(ts, tz=off42) TypeError: newfunc() got an unexpected keyword argument 'tz' ====================================================================== ERROR: test_tzinfo_now (__main__.TestDateTimeTZ) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_datetime.py", line 2385, in test_tzinfo_now again = meth(tz=off42) TypeError: newfunc() got an unexpected keyword argument 'tz' ====================================================================== 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 David
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
To speed up my testing I created a cutdown version of the non-pickle tests that failed :-) One of them fails in standard python as well so is a problem with the datetime.py code The others are all due to classmethod not accepting keyword arguments. I've attached a patch to __builtin__module.py that enables it to accept keyword arguments, which makes all those tests pass. Seems simple, could it be applied? David
David Fraser wrote:
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
To speed up my testing I created a cutdown version of the non-pickle tests that failed :-) One of them fails in standard python as well so is a problem with the datetime.py code The others are all due to classmethod not accepting keyword arguments. I've attached a patch to __builtin__module.py that enables it to accept keyword arguments, which makes all those tests pass.
Seems simple, could it be applied?
Of course attaching the patch as a patch would give too much away, so I have to send it as text/plain :-) David Index: __builtin__module.py =================================================================== --- __builtin__module.py (revision 8816) +++ __builtin__module.py (working copy) @@ -581,8 +581,8 @@ def __get__(self, obj, klass=None): if klass is None: klass = type(obj) - def newfunc(*args): - return self.f(klass, *args) + def newfunc(*args, **kwargs): + return self.f(klass, *args, **kwargs) return newfunc if not hasattr(dict, 'fromkeys'):
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.
On Feb 4, 2005, at 9:20, 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
Awesome! I'll take a look imcst but, datetime is one of my favorite modules. Thanks for working on it! Anna
Anna Ravenscroft wrote:
On Feb 4, 2005, at 9:20, 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
Awesome! I'll take a look imcst but, datetime is one of my favorite modules. Thanks for working on it!
Sure, almost all the work had already been done for me :-) David
Hi David, On Fri, Feb 04, 2005 at 10:55:08AM +0200, David Fraser wrote:
Seems simple, could it be applied?
Sure, done. Thanks for the fix, and don't hesitate to ask for check-in rights if you're doing more of them :-) Armin
Armin Rigo wrote:
Hi David,
On Fri, Feb 04, 2005 at 10:55:08AM +0200, David Fraser wrote:
Seems simple, could it be applied?
Sure, done. Thanks for the fix, and don't hesitate to ask for check-in rights if you're doing more of them :-)
Wow, cool. Let me see what happens... David
participants (3)
-
Anna Ravenscroft -
Armin Rigo -
David Fraser