[tor-commits] [arm/master] Namedtuple may not have __dict__

atagar at torproject.org atagar at torproject.org
Sun Mar 15 22:40:19 UTC 2015


commit 76a04df1aca2722320058874407624f51141985f
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Mar 15 15:35:04 2015 -0700

    Namedtuple may not have __dict__
    
    Sounds like there's a python bug where namedtuples might not have __dict__...
    
      http://ronrothman.com/public/leftbraned/python-2-7-3-bug-broke-my-namedtuple-unpickling/
    
    This manifests itself for me when starting up with...
    
      Traceback (most recent call last):
        File "./run_seth", line 47, in <module>
          main()
        File "./run_seth", line 16, in main
          seth.starter.main()
        File "/usr/lib/python2.7/stem/util/conf.py", line 288, in wrapped
          return func(*args, config = config, **kwargs)
        File "/home/atagar/Desktop/seth/seth/starter.py", line 92, in main
          curses.wrapper(seth.controller.start_seth)
        File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
          return func(stdscr, *args, **kwds)
        File "/home/atagar/Desktop/seth/seth/controller.py", line 570, in start_seth
          control.redraw(False)
        File "/home/atagar/Desktop/seth/seth/controller.py", line 401, in redraw
          panel_impl.redraw(force)
        File "/home/atagar/Desktop/seth/seth/util/panel.py", line 442, in redraw
          self.draw(self.max_x, self.max_y)
        File "/home/atagar/Desktop/seth/seth/header_panel.py", line 134, in draw
          self._draw_platform_section(0, 0, left_width, vals)
        File "/home/atagar/Desktop/seth/seth/header_panel.py", line 167, in _draw_platform_section
          x = self.addstr(y, x, vals.format('seth - {hostname}', space_left))
        File "/home/atagar/Desktop/seth/seth/header_panel.py", line 473, in format
          formatted_msg = message.format(**super(Sampling, self).__dict__)
      AttributeError: 'super' object has no attribute '__dict__'
---
 seth/header_panel.py |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/seth/header_panel.py b/seth/header_panel.py
index b0ece7d..dff3d08 100644
--- a/seth/header_panel.py
+++ b/seth/header_panel.py
@@ -469,8 +469,12 @@ def get_sampling(last_sampling = None):
   }
 
   class Sampling(collections.namedtuple('Sampling', attr.keys())):
+    def __init__(self, **attr):
+      super(Sampling, self).__init__(**attr)
+      self._attr = attr
+
     def format(self, message, crop_width = None):
-      formatted_msg = message.format(**super(Sampling, self).__dict__)
+      formatted_msg = message.format(**self._attr)
 
       if crop_width:
         formatted_msg = str_tools.crop(formatted_msg, crop_width)





More information about the tor-commits mailing list