New submission from Alexander Belopolsky <alexander.belopol...@gmail.com>:
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. ---------- title: Different behavior betwee -> Different behavior between datetime.py and its C accelerator _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33812> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com