Alexander Belopolsky <[email protected]> added the comment:
Thank you for the bug report and a patch.
This does look like a bug and proposed patch seems to be the simplest way to
fix it. It is unfortunate that the entire TimeRE cache needs to be
recalculated when only 'Z' entry is invalidated by TZ change. Please consider
separating lang and TZ change checks and not reinitialize TimeRE cache object
if only TZ changes, just replace the 'Z' entry.
The patch also needs unit tests. It should be straightforward to convert
ttime.py into a test case. Please add a test case for both test_time and
test_datetime. Note that in 3.2 datetime.strptime() will process '%Z' when
'%z' is also present. For example,
>>> datetime.strptime('Fri Jul 25 13:26:29 EDT -0500 2008', '%a %b %d %H:%M:%S
>>> %Z %z %Y')
datetime.datetime(2008, 7, 25, 13, 26, 29,
tzinfo=datetime.timezone(datetime.timedelta(-1, 68400), 'EDT'))
Please make sure to restore environment variables in test cleanup.
Also a nit on the implementation: cls is unused in _get_timezone(cls), so it
would be more appropriate to make it staticmethod instead of classmethod. And
tzset should probably be called inside _get_timezone.
----------
stage: needs patch -> unit test needed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue6478>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com