You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. While porting a library of mine from python 2.7 to 3.2 I noticed that tarfile.is_tarfile() now raises an AttributeError rather than IOError when it lacks read permissions...
atagar@morrigan:~$ python
Python 2.7.1+ (r271:86832, Sep 27 2012, 21:16:52)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tarfile
>>> tarfile.is_tarfile("/home/atagar/dummy_file.tar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/tarfile.py", line 2583, in is_tarfile
t = open(name)
File "/usr/lib/python2.7/tarfile.py", line 1658, in open
return func(name, "r", fileobj, **kwargs)
File "/usr/lib/python2.7/tarfile.py", line 1720, in gzopen
fileobj = bltn_open(name, mode + "b")
IOError: [Errno 13] Permission denied: '/home/atagar/dummy_file.tar'
atagar@morrigan:~$ python3
Python 3.2 (r32:88445, Oct 20 2012, 14:09:50)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tarfile
>>> tarfile.is_tarfile("/home/atagar/dummy_file.tar")
Traceback (most recent call last):
File "/usr/lib/python3.2/tarfile.py", line 1805, in gzopen
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
File "/usr/lib/python3.2/gzip.py", line 157, in __init__
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
IOError: [Errno 13] Permission denied: '/home/atagar/dummy_file.tar'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.2/tarfile.py", line 2593, in is_tarfile
t = open(name)
File "/usr/lib/python3.2/tarfile.py", line 1739, in open
return func(name, "r", fileobj, **kwargs)
File "/usr/lib/python3.2/tarfile.py", line 1809, in gzopen
fileobj.close()
AttributeError: 'NoneType' object has no attribute 'close'
>>> try:
... tarfile.is_tarfile("/home/atagar/dummy_file.tar")
... exceptIOError:
... print("caught an IOError")
... exceptAttributeError:
... print("caught an AttributeError")
...
caught an AttributeError
... easy to work around, but I suspect this wasn't intentional. :)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: