This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2019年04月30日 11:36 by Snidhi, last changed 2022年04月11日 14:59 by admin.
| Messages (10) | |||
|---|---|---|---|
| msg341149 - (view) | Author: Snidhi Sofpro (Snidhi) | Date: 2019年04月30日 11:36 | |
With: Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
import datetime;
d_Time = datetime.datetime.strptime('03:30 PM', '%I:%M %p');
d_Time = d_Time.astimezone(datetime.timezone.utc);
# RESULTS IN OSError: [Errno 22] Invalid argument
# WHEREAS the foll. does not have the issue!
d_Time = datetime.datetime(year = d_Time.year,
month = d_Time.month,
day = d_Time.day,
hour = d_Time.hour,
minute = d_Time.minute,
second = d_Time.second,
tzinfo = datetime.timezone.utc);
print(d_Time);
|
|||
| msg341152 - (view) | Author: Windson Yang (Windson Yang) * | Date: 2019年04月30日 13:23 | |
on macOS 10.14.4, I got `ValueError: offset must be a timedelta representing a whole number of minutes, not datetime.timedelta(0, 29143).` I will do some research to see why this happen. |
|||
| msg341157 - (view) | Author: SilentGhost (SilentGhost) * (Python triager) | Date: 2019年04月30日 16:31 | |
This seems like a duplicate (or at least very similar) to the issue 29097. Could you try a newer version of Python (that issue was fixed in 3.6.7) to make sure it's not a duplicate? That was specifically a Windows bug, Windson, make sure that what you're seeing is not fixed elsewhere if you only have macOS available. |
|||
| msg341236 - (view) | Author: Windson Yang (Windson Yang) * | Date: 2019年05月02日 00:06 | |
Thanks, SilentGhost, you are right. I will leave this to a Windows expert instead. |
|||
| msg342866 - (view) | Author: SilentGhost (SilentGhost) * (Python triager) | Date: 2019年05月19日 17:13 | |
I'm going to close this issue as a duplicate of #29097. If you're still experience this problem on python3.7, please re-open. |
|||
| msg364801 - (view) | Author: Ard Kuijpers (Ard Kuijpers) | Date: 2020年03月22日 12:31 | |
Encountered this bug on Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)], so on Windows 10. I can reproduce the bug with the code in message https://bugs.python.org/msg341149. It does not seem to be a duplicate of #29097 since I cannot reproduce that issue. |
|||
| msg364866 - (view) | Author: SilentGhost (SilentGhost) * (Python triager) | Date: 2020年03月23日 17:27 | |
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. |
|||
| msg364907 - (view) | Author: Jonathan Hsu (Jonathan Hsu) * | Date: 2020年03月23日 23:32 | |
I'd like to take on this issue if no one else is working on it. |
|||
| msg364918 - (view) | Author: Jonathan Hsu (Jonathan Hsu) * | Date: 2020年03月24日 05:43 | |
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? |
|||
| msg364921 - (view) | Author: Ard Kuijpers (Ard Kuijpers) | Date: 2020年03月24日 08:53 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:14 | admin | set | github: 80940 |
| 2020年03月24日 08:53:35 | Ard Kuijpers | set | messages: + msg364921 |
| 2020年03月24日 05:43:15 | Jonathan Hsu | set | messages: + msg364918 |
| 2020年03月23日 23:32:03 | Jonathan Hsu | set | messages: + msg364907 |
| 2020年03月23日 23:13:27 | Jonathan Hsu | set | nosy:
+ Jonathan Hsu |
| 2020年03月23日 17:27:54 | SilentGhost | set | 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 nosy: + belopolsky, p-ganssle versions: + Python 3.8, Python 3.9, - Python 3.6 messages: + msg364866 resolution: duplicate -> stage: resolved -> test needed |
| 2020年03月22日 12:31:06 | Ard Kuijpers | set | nosy:
+ Ard Kuijpers messages: + msg364801 versions: + Python 3.7 |
| 2019年05月19日 17:13:23 | SilentGhost | set | status: pending -> closed superseder: [Windows] datetime.fromtimestamp(t) when 0 <= t <= 86399 fails on Python 3.6 messages: + msg342866 resolution: duplicate stage: resolved |
| 2019年05月11日 09:43:09 | SilentGhost | set | status: open -> pending |
| 2019年05月02日 00:06:37 | Windson Yang | set | messages: + msg341236 |
| 2019年04月30日 16:31:16 | SilentGhost | set | nosy:
+ SilentGhost messages: + msg341157 |
| 2019年04月30日 13:23:55 | Windson Yang | set | nosy:
+ Windson Yang messages: + msg341152 |
| 2019年04月30日 11:36:26 | Snidhi | create | |