Skip to content

Commit 5ef8ddf

Browse files
committed
Handle Z for Python 3.10 and lower
1 parent a8f28e2 commit 5ef8ddf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pip/_internal/models/link.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import posixpath
99
import re
10+
import sys
1011
import urllib.parse
1112
from collections.abc import Mapping
1213
from dataclasses import dataclass
@@ -304,6 +305,10 @@ def from_json(
304305

305306
upload_time: datetime.datetime | None
306307
if upload_time_data := file_data.get("upload-time"):
308+
# Handle 'Z' suffix for UTC timezone (added in Python 3.11)
309+
# For Python < 3.11, convert 'Z' to '+00:00' for compatibility
310+
if sys.version_info < (3, 11) and upload_time_data.endswith("Z"):
311+
upload_time_data = upload_time_data[:-1] + "+00:00"
307312
upload_time = datetime.datetime.fromisoformat(upload_time_data)
308313
else:
309314
upload_time = None

0 commit comments

Comments
 (0)