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

[tor-commits] [stem/master] Revert "Minor simplification for cache fetches"



commit 678c3b4d3235d063ee129c8cba067c15c9808762
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Oct 28 18:07:56 2017 -0700

    Revert "Minor simplification for cache fetches"
    
    This change broke the ability for get_info() to accept unicode inputs (or bytes
    under python3)...
    
      >>> controller.get_network_status(u'0881E47137764C907E729C9303C094BD270CC27F')
      Traceback (most recent call last):
        File "<console>", line 1, in <module>
        File "/home/ubuntu/stem/stem/control.py", line 482, in wrapped
          return func(self, *args, **kwargs)
        File "/home/ubuntu/stem/stem/control.py", line 1928, in get_network_status
          desc_content = self.get_info(query, get_bytes = True)
        File "/home/ubuntu/stem/stem/control.py", line 482, in wrapped
          return func(self, *args, **kwargs)
        File "/home/ubuntu/stem/stem/control.py", line 1165, in get_info
          cached_results = self._get_cache_map(map(str.lower, params), 'getinfo')
      TypeError: descriptor 'lower' requires a 'str' object but received a 'unicode'
    
    This reverts commit e134dc59de93de3aef2ae1ec6e9b7a2f194c8eff.
---
 stem/control.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index eebc24b6..763c6dab 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1162,7 +1162,8 @@ class Controller(BaseController):
 
     # check for cached results
 
-    cached_results = self._get_cache_map(map(str.lower, params), 'getinfo')
+    from_cache = [param.lower() for param in params]
+    cached_results = self._get_cache_map(from_cache, 'getinfo')
 
     for key in cached_results:
       if key == 'address' and (time.time() - self._address_cached_at) > CACHE_ADDRESS_FOR:
@@ -2194,10 +2195,13 @@ class Controller(BaseController):
     if params == []:
       return {}
 
-    # check for cached results, translating context sensitive options
-
+    # translate context sensitive options
     lookup_params = set([MAPPED_CONFIG_KEYS.get(entry, entry) for entry in params])
-    cached_results = self._get_cache_map(map(str.lower, lookup_params), 'getconf')
+
+    # check for cached results
+
+    from_cache = [param.lower() for param in lookup_params]
+    cached_results = self._get_cache_map(from_cache, 'getconf')
 
     for key in cached_results:
       user_expected_key = _case_insensitive_lookup(lookup_params, key)

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