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

[tor-commits] [stem/master] Undefined _name() method on base Descriptor class



commit 90bb28f44929bcb33b321eb51a27bb247c4ae6ab
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Dec 5 13:25:48 2014 -0800

    Undefined _name() method on base Descriptor class
    
    Methods for parsing router status entries expect a _name() method, but it was
    only defined on the RouterStatusEntry. In theory this sounds good, but
    Microdescriptors use this too. As a result we balk with an AttributeError when
    there's validation issues...
    
      https://trac.torproject.org/projects/tor/ticket/13904
---
 docs/change_log.rst                |    1 +
 stem/descriptor/__init__.py        |    3 +++
 stem/descriptor/microdescriptor.py |    3 +++
 3 files changed, 7 insertions(+)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index e9fcac7..132043b 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -61,6 +61,7 @@ The following are only available within Stem's `git repository
   * Include '\*.new' files when reading from a Tor data directory (:trac:`13756`)
   * Updated the authorities we list, `replacing turtles with longclaw <https://lists.torproject.org/pipermail/tor-talk/2014-November/035650.html>`_ and `updating gabelmoo's address <https://lists.torproject.org/pipermail/tor-talk/2014-September/034898.html>`_
   * Noting if authorities are also a bandwidth authority or not
+  * Microdescriptor validation issues could result in an AttributeError (:trac:`13904`)
 
  * **Utilities**
 
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index e45ce1e..1527338 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -367,6 +367,9 @@ class Descriptor(object):
   def _set_archive_path(self, path):
     self._archive_path = path
 
+  def _name(self, is_plural = False):
+    return str(type(self))
+
   def __str__(self):
     if stem.prereq.is_python_3():
       return stem.util.str_tools._to_unicode(self._raw_contents)
diff --git a/stem/descriptor/microdescriptor.py b/stem/descriptor/microdescriptor.py
index c3d3db9..4702b84 100644
--- a/stem/descriptor/microdescriptor.py
+++ b/stem/descriptor/microdescriptor.py
@@ -305,6 +305,9 @@ class Microdescriptor(Descriptor):
     if "onion-key" != entries.keys()[0]:
       raise ValueError("Microdescriptor must start with a 'onion-key' entry")
 
+  def _name(self, is_plural = False):
+    return 'microdescriptors' if is_plural else 'microdescriptor'
+
   def _compare(self, other, method):
     if not isinstance(other, Microdescriptor):
       return False

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