[issue36759] astimezone() fails on Windows for pre-epoch times

2020-03-24 Thread Ard Kuijpers


Ard Kuijpers  added the comment:

It would be helpful to have a better error message than '[Errno 22] Invalid 
argument' on Windows, so a ValueError seems to be a good idea at the moment.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36759] astimezone() fails on Windows for pre-epoch times

2020-03-23 Thread Jonathan Hsu


Jonathan Hsu  added the comment:

This exception is raised because astimezone() ends up calling time.localtime() 
to determine the appropriate time zone. If the datetime object has a pre-epoch 
value, it passes a negative timestamp to time.localtime(). On Windows, 
time.localtime() does not accept values greater than 0 (more discussion in 
issue #35796).

This is the minimal code required to reproduce the error:

from datetime import datetime
datetime(1969, 1, 1).astimezone()

Without the ability to ascertain the time zone with localtime(), I'm not sure 
if the time zone can be accurately determined. It's not clear what the proper 
behavior is. Maybe raise a ValueError?

PEP 615 proposes to include the IANA tz database, which would negate the need 
for a system call. Should we wait for this PEP before fixing this issue? 
Thoughts?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36759] astimezone() fails on Windows for pre-epoch times

2020-03-23 Thread Jonathan Hsu


Jonathan Hsu  added the comment:

I'd like to take on this issue if no one else is working on it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36759] astimezone() fails on Windows for pre-epoch times

2020-03-23 Thread Jonathan Hsu


Change by Jonathan Hsu :


--
nosy: +Jonathan Hsu

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36759] astimezone() fails on Windows for pre-epoch times

2020-03-23 Thread SilentGhost

SilentGhost  added the comment:

Yes, I was also able to verify this issue on 3.8.2 on win10. Argument to 
astimezone is not required, and this happens for both naïve and aware objects.

--
nosy: +belopolsky, p-ganssle
resolution: duplicate -> 
stage: resolved -> test needed
status: closed -> open
superseder: [Windows] datetime.fromtimestamp(t) when 0 <= t <= 86399 fails on 
Python 3.6 -> 
title: datetime: astimezone() results in OSError: [Errno 22] Invalid argument 
-> astimezone() fails on Windows for pre-epoch times
versions: +Python 3.8, Python 3.9 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com