[pypy-svn] r54842 - in pypy/dist/pypy/lib: . app_test
fijal at codespeak.net
fijal at codespeak.net
Sat May 17 17:04:59 CEST 2008
Author: fijal
Date: Sat May 17 17:04:58 2008
New Revision: 54842
Added:
pypy/dist/pypy/lib/app_test/test_datetime.py (contents, props changed)
Modified:
pypy/dist/pypy/lib/datetime.py
Log:
Make datetime.datetime print the same thing as under cpython
Added: pypy/dist/pypy/lib/app_test/test_datetime.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/app_test/test_datetime.py Sat May 17 17:04:58 2008
@@ -0,0 +1,7 @@
+
+import datetime
+
+def test_repr():
+ print datetime
+ expected = "datetime.datetime(1, 2, 3, 0, 0)"
+ assert repr(datetime.datetime(1,2,3)) == expected
Modified: pypy/dist/pypy/lib/datetime.py
==============================================================================
--- pypy/dist/pypy/lib/datetime.py (original)
+++ pypy/dist/pypy/lib/datetime.py Sat May 17 17:04:58 2008
@@ -1561,8 +1561,10 @@
"Convert to formal string, for repr()."
L = [self.__year, self.__month, self.__day, # These are never zero
self.__hour, self.__minute, self.__second, self.__microsecond]
- while L[-1] == 0:
+ if L[-1] == 0:
del L[-1]
+ if L[-1] == 0:
+ del L[-1]
s = ", ".join(map(str, L))
s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s)
if self._tzinfo is not None:
More information about the Pypy-commit
mailing list