Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 Doc/deprecations/pending-removal-in-3.20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Pending removal in Python 3.20
- :mod:`re`
- :mod:`socketserver`
- :mod:`tabnanny`
- :mod:`tarfile`
- :mod:`tkinter.font`
- :mod:`tkinter.ttk`
- :mod:`wsgiref.simple_server`
Expand Down
1 change: 1 addition & 0 deletions 1 Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ New deprecations
- :mod:`re`
- :mod:`socketserver`
- :mod:`tabnanny`
- :mod:`tarfile`
- :mod:`tkinter.font`
- :mod:`tkinter.ttk`
- :mod:`wsgiref.simple_server`
Expand Down
11 changes: 10 additions & 1 deletion 11 Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"""Read from and write to tar format archives.
"""

version = "0.9.0"
__author__ = "Lars Gust\u00e4bel (lars@gustaebel.de)"
__credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend."

Expand Down Expand Up @@ -3137,5 +3136,15 @@ def main():
if args.verbose:
print('{!r} file created.'.format(tar_name))


def __getattr__(name):
Comment thread
StanFromIreland marked this conversation as resolved.
if name == "version":
from warnings import _deprecated

_deprecated("version", remove=(3, 20))
return "0.9.0" # Do not change
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

Comment thread
StanFromIreland marked this conversation as resolved.

if __name__ == '__main__':
main()
10 changes: 10 additions & 0 deletions 10 Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4836,6 +4836,16 @@ def test_ignore_invalid_offset_headers(self):
self.assertEqual(members[0].offset, expected_offset)


class TestModule(unittest.TestCase):
def test_deprecated_version(self):
with self.assertWarnsRegex(
DeprecationWarning,
"'version' is deprecated and slated for removal in Python 3.20",
) as cm:
getattr(tarfile, "version")
self.assertEqual(cm.filename, __file__)


def setUpModule():
os_helper.unlink(TEMPDIR)
os.makedirs(TEMPDIR)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The ``version`` attribute of the :mod:`tarfile` module is deprecated and
slated for removal in Python 3.20.
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.