[tor-commits] [stem/master] Replacing file() with open()

atagar at torproject.org atagar at torproject.org
Sat Feb 2 18:20:50 UTC 2013


commit 384411b26dd140e3d4b181f3c2b1a48057238096
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Feb 1 07:16:25 2013 -0800

    Replacing file() with open()
    
    I'm not sure why we were using file() at one point rather than open(), but it
    makes python 3 sad...
    
    ======================================================================
    ERROR: test_authenticate_cookie
    ----------------------------------------------------------------------
    Traceback:
      File "/home/atagar/Desktop/stem/test/data/python3/test/integ/connection/authentication.py", line 303, in test_authenticate_cookie
        self._check_auth(auth_type, auth_value)
      File "/home/atagar/Desktop/stem/test/data/python3/test/integ/connection/authentication.py", line 400, in _check_auth
        stem.connection.authenticate_cookie(control_socket, auth_arg)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/connection.py", line 583, in authenticate_cookie
        cookie_data = _read_cookie(cookie_path, False)
      File "/home/atagar/Desktop/stem/test/data/python3/stem/connection.py", line 877, in _read_cookie
        with file(cookie_path, 'rb', 0) as f:
    NameError: global name 'file' is not defined
---
 stem/connection.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stem/connection.py b/stem/connection.py
index 86d73d6..1a72399 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -874,7 +874,7 @@ def _read_cookie(cookie_path, is_safecookie):
     raise IncorrectCookieSize(exc_msg, cookie_path, is_safecookie)
 
   try:
-    with file(cookie_path, 'rb', 0) as f:
+    with open(cookie_path, 'rb', 0) as f:
       return f.read()
   except IOError, exc:
     exc_msg = "Authentication failed: unable to read '%s' (%s)" % (cookie_path, exc)





More information about the tor-commits mailing list