[issue40757] tarfile: ignore_zeros = True won't raise exception even on invalid (non-zero) TARs
Irit Katriel
report at bugs.python.org
Fri Jan 21 08:02:04 EST 2022
Irit Katriel <iritkatriel at gmail.com> added the comment:
I am unable to reproduce this on 3.11:
>>> import tarfile
>>> tarfile.open( "foo.txt" )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/iritkatriel/src/cpython-1/Lib/tarfile.py", line 1613, in open
return func(name, "r", fileobj, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/tarfile.py", line 1679, in gzopen
fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/gzip.py", line 174, in __init__
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'foo.txt'
>>> tarfile.open( "foo.txt", ignore_zeros = True )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/iritkatriel/src/cpython-1/Lib/tarfile.py", line 1613, in open
return func(name, "r", fileobj, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/tarfile.py", line 1679, in gzopen
fileobj = GzipFile(name, mode + "b", compresslevel, fileobj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/gzip.py", line 174, in __init__
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'foo.txt'
>>>
----------
nosy: +iritkatriel
resolution: -> out of date
status: open -> pending
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40757>
_______________________________________
More information about the Python-bugs-list
mailing list