classification
Title: Provide parseable repr to datetime.timezone
Type: enhancement Stage: resolved
Components: Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: 5094 Superseder:
Assigned To: belopolsky Nosy List: ajaksu2, akira, belopolsky, daniel.urban, doerwalter, eric.araujo, ezio.melotti, ggenellina, kawai, l0nwlf, mark.dickinson, pitrou, r.david.murray, rafe, techtonik, tim.peters
Priority: normal Keywords: easy, patch

Created on 2010-06-15 15:52 by belopolsky, last changed 2010-07-10 21:34 by eric.araujo. This issue is now closed.

Files
File name Uploaded Description Edit
issue9000-proto.diff belopolsky, 2010-07-06 15:21 Patch against sandbox datetime.py and test_dateime.py
issue9000.diff belopolsky, 2010-07-06 22:48 Patch for the C code with tests
Messages (6)
msg107876 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-15 15:52
Recently added datetime.timezone class does not have a custom repr, so one gets

>>> timezone.utc
<datetime.timezone object at 0x100681ef0>

instead of parseable

datetime.timezone(datetime.timedelta(0))

This is inconsistent with the way other classes in datetime module behave.
msg107877 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-15 15:54
Merged issue5094 nosy list.
msg109397 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-06 15:21
I am attaching a python prototype.  I am following the convention in place for the other datetime classes of prepending the repr with 'datetime.'.  This may not be ideal, but better than to introduce an inconsistency.  The only question I think is worth considering is the representation of timezone.utc.  I would like to have repr(timezone(timedelta(0))) == 'datetime.timezone.utc' even though currently timezone(timedelta(0)) and timezone.utc are different but equal objects.  This is going to change, however.  See issue9051.

[1] http://bugs.python.org/issue5094#msg106411
msg109436 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-06 22:42
Attaching a C patch.
msg109438 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-06 22:48
Replacing the patch.  The previously attached patch reverted issue9051 a bit too aggressively.
msg109443 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-06 23:21
Committed in r82617.  Python version committed to sandbox in r82616.
History
Date User Action Args
2010-07-10 21:34:51eric.araujosetresolution: accepted -> fixed
2010-07-06 23:21:34belopolskysetstatus: open -> closed

messages: + msg109443
stage: commit review -> resolved
2010-07-06 22:49:02belopolskysetfiles: - issue9000.diff
2010-07-06 22:48:55belopolskysetfiles: + issue9000.diff

messages: + msg109438
2010-07-06 22:42:01belopolskysetfiles: + issue9000.diff
resolution: accepted
messages: + msg109436

stage: test needed -> commit review
2010-07-06 15:21:38belopolskysetfiles: + issue9000-proto.diff
keywords: + patch
messages: + msg109397
2010-06-16 04:33:02brett.cannonsetnosy: - brett.cannon
2010-06-15 15:54:32belopolskysetnosy: + tim.peters, doerwalter, brett.cannon, mark.dickinson, ggenellina, pitrou, techtonik, ajaksu2, kawai, ezio.melotti, eric.araujo, r.david.murray, rafe, daniel.urban, l0nwlf, akira
messages: + msg107877
2010-06-15 15:53:22belopolskysetdependencies: + datetime lacks concrete tzinfo implementation for UTC
versions: + Python 3.2
2010-06-15 15:52:46belopolskycreate