FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-76007: Deprecate `tarfile.version` by StanFromIreland · Pull Request #145326 · python/cpython · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (2) .rst  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions Doc/deprecations/pending-removal-in-3.20.rst
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
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 Doc/whatsnew/3.15.rst
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
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 Lib/tarfile.py
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
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 Lib/test/test_tarfile.py
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
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
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
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

Back | FazBrowse Home | New Git URL