[tor-commits] [stem/master] Including all entries in the Event's positional_args

atagar at torproject.org atagar at torproject.org
Tue Dec 4 17:07:37 UTC 2012


commit 7011a6a2f1c306e204eb6e518604911d5561fc71
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Dec 4 08:00:58 2012 -0800

    Including all entries in the Event's positional_args
    
    Fixing a semi-bug where the Event's positional_args only contained entries that
    we didn't recognize. This was a bug according to the Event's pydoc, but by
    design according to an inline comment. I'm not really sure what I did that - oh
    well...
---
 stem/response/events.py |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/stem/response/events.py b/stem/response/events.py
index dbd23f9..30350a3 100644
--- a/stem/response/events.py
+++ b/stem/response/events.py
@@ -81,32 +81,31 @@ class Event(stem.response.ControlMessage):
       else:
         break
     
-    self.positional_args = content.split()[1:]
+    # Setting attributes for the fields that we recognize.
     
-    # Setting attributes for the fields that we recognize. Unrecognized fields
-    # only appear in our 'positional_args' and 'keyword_args' attributes.
+    self.positional_args = content.split()[1:]
+    positional = list(self.positional_args)
     
-    for i in xrange(len(self._POSITIONAL_ARGS)):
-      attr_name = self._POSITIONAL_ARGS[i]
+    for attr_name in self._POSITIONAL_ARGS:
       attr_value = None
       
-      if self.positional_args:
+      if positional:
         if attr_name in self._QUOTED:
-          attr_values = [self.positional_args.pop(0)]
+          attr_values = [positional.pop(0)]
           
           if not attr_values[0].startswith('"'):
             raise stem.ProtocolError("The %s value should be quoted, but didn't have a starting quote: %s" % self)
           
           while True:
-            if not self.positional_args:
+            if not positional:
               raise stem.ProtocolError("The %s value should be quoted, but didn't have an ending quote: %s" % self)
             
-            attr_values.append(self.positional_args.pop(0))
+            attr_values.append(positional.pop(0))
             if attr_values[-1].endswith('"'): break
           
           attr_value = " ".join(attr_values)[1:-1]
         else:
-          attr_value = self.positional_args.pop(0)
+          attr_value = positional.pop(0)
       
       setattr(self, attr_name, attr_value)
     





More information about the tor-commits mailing list