Skip to content

Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)#95

Open
jelson wants to merge 1 commit into
rossengeorgiev:masterfrom
jelson:fix-utcnow-deprecation
Open

Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)#95
jelson wants to merge 1 commit into
rossengeorgiev:masterfrom
jelson:fix-utcnow-deprecation

Conversation

@jelson
Copy link
Copy Markdown

@jelson jelson commented May 20, 2026

Fixes the DeprecationWarning emitted on every parsed packet under Python 3.12+ from aprslib/parsing/common.py:83.

parse_timestamp's public output (int unix timestamp) is unchanged; the test was adjusted to use a tz-aware 1970 reference.

Used timezone.utc rather than datetime.UTC (3.11+) for broader Python 3 support. This does drop Python 2.7, which has been EOL since 2020.

pytest tests/test_parse_common.py passes with no DeprecationWarning.

datetime.utcnow() emits DeprecationWarning under Python 3.12+ and is
scheduled for removal in a future version. Switch to the recommended
timezone-aware alternative.

Note: datetime.timezone is Python 3.2+, so this drops Python 2.7
support. Python 2.7 has been EOL since 2020.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant