Skip to content

Commit e6b564b

Browse files
authored
Merge pull request #682 from wimglenn/utcfromtimestamp
datetime.utcfromtimestamp is deprecated in Python 3.12, avoid using it
2 parents 6ba8c7e + 4ea699e commit e6b564b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

flit_core/flit_core/wheel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
from base64 import urlsafe_b64encode
33
import contextlib
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55
import hashlib
66
import io
77
import logging
@@ -42,7 +42,8 @@ def zip_timestamp_from_env() -> Optional[tuple]:
4242
try:
4343
# If SOURCE_DATE_EPOCH is set (e.g. by Debian), it's used for
4444
# timestamps inside the zip file.
45-
d = datetime.utcfromtimestamp(int(os.environ['SOURCE_DATE_EPOCH']))
45+
t = int(os.environ['SOURCE_DATE_EPOCH'])
46+
d = datetime.fromtimestamp(t, timezone.utc)
4647
except (KeyError, ValueError):
4748
# Otherwise, we'll use the mtime of files, and generated files will
4849
# default to 2016-1-1 00:00:00

0 commit comments

Comments
 (0)