-
Notifications
You must be signed in to change notification settings - Fork 325
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 leap day parsing warning on python3.13 #1451
Comments
@rafsaf We have to time format with public static final DateTimeFormatter HTTP_HEADER_DATE_FORMAT =
DateTimeFormatter.ofPattern("EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'", Locale.US).withZone(UTC); If we fix it like java code, it is much better. |
Thanks! That is valuable input about the context @balamurugana, indeed looks interesting. At minimum %Y can be added for the " %d " part to fix the actual problem and not try to change the world :p As I said I can look at it, have a nice day! |
@rafsaf I guess below is the fix diff --git a/minio/time.py b/minio/time.py
index 39a57c6..6dc3552 100644
--- a/minio/time.py
+++ b/minio/time.py
@@ -74,7 +74,10 @@ def from_http_header(value: str) -> datetime:
f"time data {value} does not match HTTP header format")
weekday = _WEEK_DAYS.index(value[0:3])
- day = datetime.strptime(value[4:8], " %d ").day
+ if value[4] != " " or value[7] != " ":
+ raise ValueError(
+ f"time data {value} does not match HTTP header format")
+ day = int(value[5:7])
if value[8:11] not in _MONTHS:
raise ValueError( |
Hello! There is a warning in the code of
time.py
on 3.13:It's related to this PR in cpython: https://github.com/python/cpython/pull/117107/files
long story short looking at
time.py
module at first glance:from_http_header
andto_http_header
should usedatetime.strptime(value, "%a, %d %b %Y %H:%M:%S %Z")
(and equivalent strftime) instead of hand crafted parsing RFC2616 date format.datetime.now(timezone.utc)
should do the trickIf anybody want to play with that, feel free, i will find myself some spare time in a few days to prepare PR
PS. Maybe I'm wrong and
"%a, %d %b %Y %H:%M:%S %Z"
is wrong for some reason in some situations and that's why it's custom code here? But I am not aware of such thing.Rafał
The text was updated successfully, but these errors were encountered: