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

[tor-commits] [nyx/master] New tor config options crashed nyx when shown



commit 933cc48ea2bd8ce0e7e1c3f3ab9535a28e31d57a
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Nov 28 11:27:08 2017 -0800

    New tor config options crashed nyx when shown
    
    Oops! When tor provided an option stem didn't yet have manual information for
    unexpected None values caused us to stacktrace...
    
      https://trac.torproject.org/projects/tor/ticket/24401
    
      File "/usr/local/bin/nyx", line 11, in <module>
          sys.exit(main())
        ...
        File "/usr/local/lib/python3.5/dist-packages/nyx/panel/config.py", line 315, in _draw
          _draw_line(subwindow, scroll_offset, DETAILS_HEIGHT + i, entry, entry == selected, value_width, description_width)
        File "/usr/local/lib/python3.5/dist-packages/nyx/panel/config.py", line 335, in _draw_line
          attr = [CONFIG['attr.config.category_color'].get(entry.category, WHITE)]
        File "/usr/local/lib/python3.5/dist-packages/nyx/panel/config.py", line 136, in category
          return getattr(manual(self.name), 'category')
      AttributeError: 'NoneType' object has no attribute 'category'
    
    In practice I expect this only comes up when pressing 'a' to show all config
    options. That said, none the less an icky bug.
---
 nyx/panel/config.py      | 22 +++++++++++++++-------
 web/changelog/index.html |  6 ++++++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index c51c609..67ab218 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -133,19 +133,19 @@ class ConfigEntry(object):
 
   @property
   def category(self):
-    return getattr(manual(self.name), 'category')
+    return getattr(manual(self.name), 'category', '')
 
   @property
   def usage(self):
-    return getattr(manual(self.name), 'usage')
+    return getattr(manual(self.name), 'usage', '')
 
   @property
   def summary(self):
-    return getattr(manual(self.name), 'summary')
+    return getattr(manual(self.name), 'summary', '')
 
   @property
   def description(self):
-    return getattr(manual(self.name), 'description')
+    return getattr(manual(self.name), 'description', '')
 
   @property
   def position(self):
@@ -348,12 +348,20 @@ def _draw_selection_details(subwindow, selected):
   Shows details of the currently selected option.
   """
 
-  attr = ', '.join(('custom' if selected.is_set() else 'default', selected.value_type, 'usage: %s' % selected.usage))
+  attr = ['custom' if selected.is_set() else 'default', selected.value_type]
+
+  if selected.usage:
+    attr.append('usage: %s' % selected.usage)
+
   selected_color = CONFIG['attr.config.category_color'].get(selected.category, WHITE)
   subwindow.box(0, 0, subwindow.width, DETAILS_HEIGHT)
 
-  subwindow.addstr(2, 1, '%s (%s Option)' % (selected.name, selected.category), selected_color, BOLD)
-  subwindow.addstr(2, 2, 'Value: %s (%s)' % (selected.value(), str_tools.crop(attr, max(0, subwindow.width - len(selected.value()) - 13))), selected_color, BOLD)
+  if selected.category:
+    subwindow.addstr(2, 1, '%s (%s Option)' % (selected.name, selected.category), selected_color, BOLD)
+  else:
+    subwindow.addstr(2, 1, selected.name, selected_color, BOLD)
+
+  subwindow.addstr(2, 2, 'Value: %s (%s)' % (selected.value(), str_tools.crop(', '.join(attr), max(0, subwindow.width - len(selected.value()) - 13))), selected_color, BOLD)
 
   description = 'Description: %s' % selected.description
 
diff --git a/web/changelog/index.html b/web/changelog/index.html
index 54737d5..c47869b 100644
--- a/web/changelog/index.html
+++ b/web/changelog/index.html
@@ -73,6 +73,12 @@
             <li>Geoip information unavailable for inbound connections</li>
           </ul>
         </li>
+
+        <li><span class="component">Configuration Editor</span>
+          <ul>
+            <li>New tor configuration options crashed nyx when shown (<b><a href="https://trac.torproject.org/projects/tor/ticket/24401";>ticket</a></b>)
+          </ul>
+        </li>
       </ul>
 
       <div id="version-2-0" class="section"></div>

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