[tor-commits] [stem/master] Use size attribute on TarInfo rather than ExFileObject

atagar at torproject.org atagar at torproject.org
Mon Jan 18 16:42:11 UTC 2016


commit 29e98ac500e810f20696ed569553741d8ccd0c25
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jan 18 08:17:51 2016 -0800

    Use size attribute on TarInfo rather than ExFileObject
    
    Bah. With python 2.7 and 3.2 this worked but Karsten points out that with
    python 3.5 it chokes with...
    
      measure_average_advertised_bandwidth('../res/server-descriptors-2015-11.tar')
        File "metrics.py", line 9, in measure_average_advertised_bandwidth
          for desc in parse_file(path):
        File "/Users/karsten/Desktop/performance-comparison/stem/stem/descriptor/__init__.py", line 171, in parse_file
          for desc in handler(descriptor_file, descriptor_type, validate, document_handler, **kwargs):
        File "/Users/karsten/Desktop/performance-comparison/stem/stem/descriptor/__init__.py", line 246, in _parse_file_for_tar_path
          for desc in parse_file(tar_file, *args, **kwargs):
        File "/Users/karsten/Desktop/performance-comparison/stem/stem/descriptor/__init__.py", line 171, in parse_file
          for desc in handler(descriptor_file, descriptor_type, validate, document_handler, **kwargs):
        File "/Users/karsten/Desktop/performance-comparison/stem/stem/descriptor/__init__.py", line 259, in _parse_file_for_tarfile
          if entry.size == 0:
      AttributeError: 'ExFileObject' object has no attribute 'size'
    
    Docs definitely say the TarInfo has a size attribute so using that instead...
    
      https://docs.python.org/3.5/library/tarfile.html#tarinfo-objects
---
 stem/descriptor/__init__.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 6b18d65..dc7c1df 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -256,7 +256,7 @@ def _parse_file_for_tarfile(descriptor_file, *args, **kwargs):
     if tar_entry.isfile():
       entry = descriptor_file.extractfile(tar_entry)
 
-      if entry.size == 0:
+      if tar_entry.size == 0:
         continue
 
       try:



More information about the tor-commits mailing list