[tor-commits] [stem/master] Fixing circular import

atagar at torproject.org atagar at torproject.org
Wed Aug 22 01:12:46 UTC 2012


commit fc736ff07c2ded068ee3e5b9ad1028923ee89c47
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Aug 17 10:07:55 2012 -0700

    Fixing circular import
    
    Correcting a circular import between the connection and control modules...
    
    >>> import test.prompt
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "test/prompt.py", line 15, in <module>
        import stem.control
      File "stem/control.py", line 48, in <module>
        import stem.connection
      File "stem/connection.py", line 106, in <module>
        def connect_port(control_addr = "127.0.0.1", control_port = 9051, password = None, chroot_path = None, controller = stem.control.Controller):
    AttributeError: 'module' object has no attribute 'control'
---
 stem/control.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 0d7bb04..aca6f41 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -45,7 +45,6 @@ import time
 import Queue
 import threading
 
-import stem.connection
 import stem.response
 import stem.socket
 import stem.version
@@ -646,6 +645,7 @@ class Controller(BaseController):
     :raises: see :func:`stem.connection.authenticate`
     """
     
+    import stem.connection
     stem.connection.authenticate(self, *args, **kwargs)
   
   def protocolinfo(self):
@@ -659,6 +659,7 @@ class Controller(BaseController):
       * :class:`stem.socket.SocketError` if problems arise in establishing or using the socket
     """
     
+    import stem.connection
     return stem.connection.get_protocolinfo(self)
   
   def get_conf(self, param, default = UNDEFINED, multiple = False):





More information about the tor-commits mailing list