[issue27590] tarfile module next() method hides exceptions

2021-04-26 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.11 -Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-25 Thread Yujie Chen

Yujie Chen added the comment:

I do want tarfile module to stop at the first invalid header. My question is 
why does tarfile module NOT throw exception about the error in header, instead 
it just hide it silently.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-24 Thread Lars Gustäbel

Lars Gustäbel added the comment:

The question is what you're trying to accomplish. If you just want to prevent 
tarfile from stopping at the first invalid header in order to extract 
everything following it, you may use the ignore_zeros=True keyword argument.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-22 Thread Yujie Chen

Yujie Chen added the comment:

Yeah, I just tried on Python3.5 and it didn't report any errors either.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-22 Thread R. David Murray

R. David Murray added the comment:

OK, I've closed #16858 in favor of this one, since we at least had some 
discussion here.

I see you selected 2.7.  Does python3 have the same issues? (I'm guessing it 
does, though there has been some work done on the module.)

--
nosy: +mmarkk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-22 Thread Yujie Chen

Yujie Chen added the comment:

The other issue is 
http://bugs.python.org/issue16858

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-22 Thread R. David Murray

R. David Murray added the comment:

That would be my guess.  If we are reading along and we hit garbage data, we 
assume we've reached the end of the tar.  That doesn't mean there isn't room 
for improvement, or perhaps issuing a warning message about why we think we hit 
the end of the tar.

What is the issue number of the other issue?  If it is still open we should 
consolidate the issues if appropriate.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27590] tarfile module next() method hides exceptions

2016-07-22 Thread Yujie Chen

New submission from Yujie Chen:

I have seen a similar ticket, however that was opened 2 years ago and has 
nothing more than a brief description. So I opened this new one here, hoping to 
get some answers.

tarfile.TarFile object is iterable and has a next() method. next() will parse 
the header and save parsed info. During parsing, a lot of checks are done, to 
make sure the header is valid. And if there is something wrong with the header, 
exceptions will be thrown. next() catches a lot of them but not reraise what it 
catches in all cases.

I have a tgz file, one of the headers is corrupted with a wrong checksum 
section. thus during parsing, InvalidHeaderError was thrown. next() catches 
that but hide it silently. From source code 
(https://hg.python.org/cpython/file/2.7/Lib/tarfile.py#l2335), we can see that 
InvalidHeaderError will ONLY be raised if it happens in the beginning of the 
tar file. Actually, a lot of exceptions are hidden by tarfile module. tarfile 
module simply thinks these exceptions mark the end of tarball.

Why does tarfile module hide so many exceptions? or in other words, why does 
tarfile treat these exceptions as the end marker of tarball but not errors?

Is it because of this from GNU doc:
"At the end of the archive file there are two 512-byte blocks filled with 
binary zeros as an end-of-file marker. A reasonable system should write such 
end-of-file marker at the end of an archive, but must not assume that such a 
block exists when reading an archive."?

Thanks!

--
components: Library (Lib)
messages: 270990
nosy: JieGhost
priority: normal
severity: normal
status: open
title: tarfile module next() method hides exceptions
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com