New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datetime.datetime.fromtimestamp(0, tzlocal()) throws error #82826
Comments
Discovered this while trying to use a function in Can replicate through this:
|
For me, it seems that dateutil is not a standard Python library module. When I run
|
Python 3.9.0a0 (heads/master:112f2b805b, Nov 1 2019, 10:48:20)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> utc_tzinfo = datetime.timezone.utc
>>> print(datetime.datetime.fromtimestamp(0, utc_tzinfo))
1970-01-01 00:00:00+00:00 works properly on my Linux machine. |
I think it might be something Windows specific; the original comment includes the version and code to reproduce. |
Can you run
|
It is windows specific, but I don't think this is a dateutil bug rather than the python stdlib: Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> from dateutil.tz import tzlocal
>>> print(datetime.datetime.fromtimestamp(0, tzlocal()))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python365\lib\site-packages\dateutil\tz\_common.py", line 144, in fromutc
return f(self, dt)
File "D:\Python365\lib\site-packages\dateutil\tz\_common.py", line 258, in fromutc
dt_wall = self._fromutc(dt)
File "D:\Python365\lib\site-packages\dateutil\tz\_common.py", line 238, in _fromutc
dtdst = enfold(dt, fold=1).dst()
File "D:\Python365\lib\site-packages\dateutil\tz\tz.py", line 225, in dst
if self._isdst(dt):
File "D:\Python365\lib\site-packages\dateutil\tz\tz.py", line 288, in _isdst
if self.is_ambiguous(dt):
File "D:\Python365\lib\site-packages\dateutil\tz\tz.py", line 250, in is_ambiguous
(naive_dst != self._naive_is_dst(dt - self._dst_saved)))
File "D:\Python365\lib\site-packages\dateutil\tz\tz.py", line 254, in _naive_is_dst
return time.localtime(timestamp + time.timezone).tm_isdst
OSError: [Errno 22] Invalid argument As you can see, none of that backtrace is within Python, it's all inside dateutil code. More than likely they are calling |
Err...I mean I think this is a dateutil bug rather than in the Python stdlib. |
Yeah, seconded with my own tracing as well. |
Closing, here's the bug in dateutil's repo: dateutil/dateutil#197 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: