Repository navigation
Fix deprecated UTC and tar extraction calls #75 - #111
Open
shashank-tomar0 wants to merge 1 commit into
Open
shashank-tomar0 wants to merge 1 commit into
shashank-tomar0 wants to merge 1 commit into
Conversation
shashank-tomar0
force-pushed
the
fix/deprecation-warnings
branch
from
November 8, 2026 08:09
f272a09 to
44c237e
Compare
* Use a timezone-aware datetime in time2tstamp() and drop the timezone to keep returning a naive UTC datetime as before. * Pass an explicit filter to TarFile.extractall() when supported. This silences the Python 3.12+ DeprecationWarning and keeps the historical extraction behavior with the "fully_trusted" filter on Python 3.14+. * Add tests for the timestamps and for tar extraction with and without an explicit filter. Signed-off-by: Shashank Tomar <shashank.tomar912@gmail.com>
shashank-tomar0
force-pushed
the
fix/deprecation-warnings
branch
from
November 8, 2026 08:13
44c237e to
4a5c4ec
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #75.
This removes both
DeprecationWarnings reported in the issue.Changes
src/commoncode/timeutils.py:time2tstamp()now usesdatetime.now(timezone.utc).replace(tzinfo=None). Droppingtzinfokeepsthe historical naive-UTC return value and the timestamp format unchanged.
src/commoncode/archive.py: added a small_extractall()helper that alwayspasses an explicit
filtertoTarFile.extractall()when the running Pythonsupports it, with a
TypeErrorfallback for older versions.fully_trusted, which preserves the historical extractionbehavior when Python 3.14 changes the default filter to
data.filterargument ofextract_tar()is now honored on everyPython that supports it. Previously it was only passed on Python 3.14.
filterargument (CI also runs 3.10) the argumentis still ignored as before instead of raising a
TypeError.Tests
New coverage:
test_time2tstamp_does_not_emit_deprecation_warningstest_extract_tar_does_not_emit_a_deprecation_warningtest_extract_tar_raw_does_not_emit_a_deprecation_warningtest_extract_tar_honors_an_explicit_filtertest_extractall_falls_back_on_pythons_without_filters, which simulates aPython without tar extraction filters and checks the legacy call path.
test_extract_tar_honors_an_explicit_filteris skipped on Python versionsolder than 3.12, where
tarfile.FilterErrordoes not exist.The existing
test_time2tstamp_tstamp2time_is_idempotentwas updated to buildits datetime without
utcnow()as well.The full
commoncodesuite was also run locally (406 passed, 12 skipped, 1 failed). The single failure istests/test_distro.py::TestDistro::test_parse_os_release, which expectstests/data/distro/os-release/ubuntu/ubuntu-artful.txt-expected.json. Theubuntu-artful.txtfixture is a symlink in the repository, checked out as aplain file on Windows, so this failure is unrelated to this change and
reproduces on unmodified
main.