Skip to content

Commit

Permalink
Remove use of deprecated datetime.datetime methods
Browse files Browse the repository at this point in the history
The methods `datetime.datetime.utc` and `.utcfromtimestamp` were marked
deprecated in Python 3.12 in favour of `now(tz=datetime.timezone.utc)`
and `fromtimestamp(tz=datetime.timezone.utc)` [1].

[1]: python/cpython#103857
  • Loading branch information
jakelishman committed Sep 22, 2023
1 parent 363fa3c commit 0d45488
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -5,6 +5,9 @@ subunit release notes
NEXT (In development)
---------------------

* Removed use of deprecated "utc" and "utcfromtimestamp"
methods of "datetime.datetime". (Jake Lishman)

1.4.3 (2023-09-17)
---------------------

Expand Down
2 changes: 1 addition & 1 deletion python/subunit/test_results.py
Expand Up @@ -192,7 +192,7 @@ def _before_event(self):
time = self._time
if time is not None:
return
time = datetime.datetime.utcnow().replace(tzinfo=iso8601.UTC)
time = datetime.datetime.now(tz=iso8601.UTC)
self.decorated.time(time)

def progress(self, offset, whence):
Expand Down
2 changes: 1 addition & 1 deletion python/subunit/v2.py
Expand Up @@ -46,7 +46,7 @@
FLAG_MIME_TYPE = 0x0020
FLAG_EOF = 0x0010
FLAG_FILE_CONTENT = 0x0040
EPOCH = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=iso8601.UTC)
EPOCH = datetime.datetime.fromtimestamp(0, tz=iso8601.UTC)
NUL_ELEMENT = b'\0'[0]
# Contains True for types for which 'nul in thing' falsely returns false.
_nul_test_broken = {}
Expand Down

0 comments on commit 0d45488

Please sign in to comment.