[tor-commits] [stem/master] Error when trying to parse the last line in router_status_entry.parse_file()

atagar at torproject.org atagar at torproject.org
Sun Nov 4 00:15:50 UTC 2012


commit 9fa93cb5cb84a73defd7ccfcdffe82896684d03a
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Nov 3 17:12:52 2012 -0700

    Error when trying to parse the last line in router_status_entry.parse_file()
    
    When calling the Controller's get_network_statuses() method the last line would
    cause an exception because we tried to parse an empty string as a router status
    entry. Aborting when we get to the end instead.
---
 stem/descriptor/router_status_entry.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py
index 321b7c0..95f955b 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -61,7 +61,11 @@ def parse_file(document_file, validate, entry_class, entry_keyword = "r", start_
   document_file.seek(start_position)
   while not end_position or document_file.tell() < end_position:
     desc_content = "".join(stem.descriptor._read_until_keywords(entry_keyword, document_file, ignore_first = True, end_position = end_position))
-    yield entry_class(desc_content, validate, *extra_args)
+    
+    if desc_content:
+      yield entry_class(desc_content, validate, *extra_args)
+    else:
+      break
 
 class RouterStatusEntry(stem.descriptor.Descriptor):
   """



More information about the tor-commits mailing list