[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Error when trying to parse the last line in router_status_entry.parse_file()
commit 9fa93cb5cb84a73defd7ccfcdffe82896684d03a
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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):
"""
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits