Message86958
The output of repr on an object of type time.struct_time has changed
from 2.5 to 2.6, and can no longer be read in with an eval.
2.5 behaviour:
Python 2.5.4 (r254:67916, Apr 4 2009, 17:55:16)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> t1 = time.gmtime()
>>> t1_repr = repr(t1)
>>> t1_repr
'(2009, 5, 2, 16, 16, 43, 5, 122, 0)'
>>> t2 = eval(t1_repr)
>>> t1 == t2
True
Meanwhile in 2.6:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> t1 = time.gmtime()
>>> t1_repr = repr(t1)
>>> t1_repr
'time.struct_time(tm_year=2009, tm_mon=5, tm_mday=2, tm_hour=16,
tm_min=20, tm_sec=54, tm_wday=5, tm_yday=122, tm_isdst=0)'
>>> t2 = eval(t1_repr)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
TypeError: structseq() takes at most 2 arguments (9 given)
Obviously returning a time.time_struct based representation is the right
thing to do, but the repr of this flavour should eval. |
|
Date |
User |
Action |
Args |
2009-05-02 16:30:43 | jwm | set | recipients:
+ jwm |
2009-05-02 16:30:43 | jwm | set | messageid: <1241281843.36.0.110450032545.issue5907@psf.upfronthosting.co.za> |
2009-05-02 16:30:42 | jwm | link | issue5907 messages |
2009-05-02 16:30:40 | jwm | create | |
|