[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] The 'name' attribute of TarInfo classes can't be set in python 3



commit 98fd0a7ba4787340d05d0baf341594555da87d00
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Mar 18 16:36:11 2013 -0700

    The 'name' attribute of TarInfo classes can't be set in python 3
    
    Workaround for the 'name' attribute being unwriteable in python 3. On
    reflection this is a little more elegant than our prior hack. :)
    
    Exception in thread Descriptor Reader:
    Traceback (most recent call last):
      File "/home/atagar/Python-3.3.0/Lib/threading.py", line 639, in _bootstrap_inner
        self.run()
      File "/home/atagar/Python-3.3.0/Lib/threading.py", line 596, in run
        self._target(*self._args, **self._kwargs)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/descriptor/reader.py", line 435, in _read_descriptor_files
        self._handle_file(target, new_processed_files)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/descriptor/reader.py", line 514, in _handle_file
        self._handle_archive(target)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/descriptor/reader.py", line 557, in _handle_archive
        entry.name = target
    AttributeError: attribute 'name' of '_io.BufferedReader' objects is not writable
---
 stem/descriptor/reader.py |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index f3b77ae..4fb6ff4 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -548,20 +548,13 @@ class DescriptorReader(object):
         if tar_entry.isfile():
           entry = tar_file.extractfile(tar_entry)
 
-          # The parse_file() function uses the 'name' attribute to figure out
-          # the file that it came from. In the case of TarInfo instances the
-          # 'name' is the path within the archive. We'll want that for
-          # _set_archive_path().
-
-          archive_path = entry.name
-          entry.name = target
-
           try:
             for desc in stem.descriptor.parse_file(entry, validate = self._validate, document_handler = self._document_handler):
               if self._is_stopped.isSet():
                 return
 
-              desc._set_archive_path(archive_path)
+              desc._set_path(os.path.abspath(target))
+              desc._set_archive_path(entry.name)
               self._unreturned_descriptors.put(desc)
               self._iter_notice.set()
           except TypeError, exc:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits