Message319121
Consider the following code:
$ cat bug.py
import sys
if len(sys.argv) > 1:
sys.modules['_datetime'] = None
from datetime import tzinfo, datetime, timezone
class TZ(tzinfo):
def utcoffset(self, t):
pass
print(datetime(2000,1,1,tzinfo=TZ()).astimezone(timezone.utc))
When running with no arguments (with C acceleration), I get
$ ./python.exe bug.py
2000-01-01 00:00:00+00:00
but the pure python code produces an error
$ ./python.exe bug.py pure
Traceback (most recent call last):
File "bug.py", line 10, in <module>
print(datetime(2000,1,1,tzinfo=TZ()).astimezone(timezone.utc))
File ".../Lib/datetime.py", line 1783, in astimezone
raise ValueError("astimezone() requires an aware datetime")
ValueError: astimezone() requires an aware datetime
Note that some kind of error is expected because TZ.utcoffset() returns None instead of a timedelta, but the error message produced by pure python code is confusing. |
|
Date |
User |
Action |
Args |
2018-06-09 00:08:08 | belopolsky | set | recipients:
+ belopolsky |
2018-06-09 00:08:08 | belopolsky | set | messageid: <1528502888.29.0.592728768989.issue33812@psf.upfronthosting.co.za> |
2018-06-09 00:08:08 | belopolsky | link | issue33812 messages |
2018-06-09 00:08:05 | belopolsky | create | |
|