Open Nipsuli opened 6 years ago
Cannot use copy.deepcopy for datetime objects created with udatetime as deepcopy fails for rfc3339.FixedOffset_type. Example:
copy.deepcopy
datetime
udatetime
deepcopy
rfc3339.FixedOffset_type
>>> import udatetime >>> import datetime >>> import pytz >>> from copy import deepcopy >>> dtu = udatetime.now() >>> # deepcopy fails ... deepcopy(dtu) Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/local/lib/python3.7/copy.py", line 274, in _reconstruct y = func(*args) File "/usr/local/lib/python3.7/copy.py", line 273, in <genexpr> args = (deepcopy(arg, memo) for arg in args) File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/local/lib/python3.7/copy.py", line 274, in _reconstruct y = func(*args) TypeError: function takes exactly 1 argument (0 given) >>> deepcopy(dtu.tzinfo) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/copy.py", line 180, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/local/lib/python3.7/copy.py", line 274, in _reconstruct y = func(*args) TypeError: function takes exactly 1 argument (0 given) >>> # compared to e.g. pytz as tzinfo ... tz = pytz.timezone('Europe/Helsinki') >>> dt = tz.localize(dtu.replace(tzinfo=None)) >>> deepcopy(dt) datetime.datetime(2018, 7, 6, 19, 0, 32, 153444, tzinfo=<DstTzInfo 'Europe/Helsinki' EEST+3:00:00 DST>)
Using e.g. pytz as tzinfo works fine. Using: Python 3.7.0 udatetime 0.0.16
tzinfo
@freach This seems to be a significant problem, being able to copy datetimes is important.
Any plan to fix it? Do you accept PR?
Cannot use
copy.deepcopy
fordatetime
objects created withudatetime
asdeepcopy
fails forrfc3339.FixedOffset_type
. Example:Using e.g. pytz as
tzinfo
works fine. Using: Python 3.7.0 udatetime 0.0.16