commit e99dc2b618cb33d5e23166510d224429b8f67046 Author: Damian Johnson atagar@torproject.org Date: Sun Jan 27 19:53:32 2013 -0800
Accounting for tarfile.is_tarfile() raising AttributeErrors
When we lack read permissions the tarfile.is_tarfile() funcion raises an AttributeError with python 3 (rather than an IOError as it does with python 2). This is most likely a bug...
http://bugs.python.org/issue17059
Working around it for now. --- stem/descriptor/reader.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py index a6fd229..877d230 100644 --- a/stem/descriptor/reader.py +++ b/stem/descriptor/reader.py @@ -488,11 +488,16 @@ class DescriptorReader(object):
# Checking if it's a tar file may fail due to permissions so failing back # to the mime type... - # IOError: [Errno 13] Permission denied: '/vmlinuz.old' + # + # IOError: [Errno 13] Permission denied: '/vmlinuz.old' + # + # With python 3 insuffient permissions raises an AttributeError instead... + # + # http://bugs.python.org/issue17059
try: is_tar = tarfile.is_tarfile(target) - except IOError: + except (IOError, AttributeError): is_tar = target_type[0] == 'application/x-tar'
if target_type[0] in (None, 'text/plain'):
tor-commits@lists.torproject.org