commit 1b9a68b10668ce2ef77422d0f4e7c10550c4564d Author: Damian Johnson atagar@torproject.org Date: Mon Sep 4 13:47:34 2017 -0700
Immutability check for set_conf() didn't work with python3
Yet another bytes-verses-unicode gotcha.
====================================================================== ERROR: test_set_conf_when_immutable ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/require.py", line 58, in wrapped return func(self, *args, **kwargs) File "/home/atagar/Desktop/stem/test/integ/control/controller.py", line 778, in test_set_conf_when_immutable self.assertRaisesRegexp(stem.InvalidArguments, "DisableAllSwap cannot be changed while tor's running", controller.set_conf, 'DisableAllSwap', '1') File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 272, in assertRaisesRegexp return super(original_type, self).assertRaisesRegexp(exc_type, exc_msg, func, *args, **kwargs) File "/usr/lib/python3.5/unittest/case.py", line 1311, in deprecated_func return original_func(*args, **kwargs) File "/usr/lib/python3.5/unittest/case.py", line 1258, in assertRaisesRegex return context.handle('assertRaisesRegex', args, kwargs) File "/usr/lib/python3.5/unittest/case.py", line 176, in handle callable_obj(*args, **kwargs) File "/home/atagar/Desktop/stem/stem/control.py", line 2303, in set_conf self.set_options({param: value}, False) File "/home/atagar/Desktop/stem/stem/control.py", line 2412, in set_options raise stem.InvalidRequest(response.code, response.message) stem.InvalidRequest: Transition not allowed: While Tor is running, changing DisableAllSwap is not allowed.
---------------------------------------------------------------------- --- stem/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/stem/control.py b/stem/control.py index 7dc632bb..048d9e90 100644 --- a/stem/control.py +++ b/stem/control.py @@ -328,7 +328,7 @@ Listener = stem.util.enum.UppercaseEnum(
# torrc options that cannot be changed once tor's running
-IMMUTABLE_CONFIG_OPTIONS = map(str.lower, ( +IMMUTABLE_CONFIG_OPTIONS = set(map(stem.util.str_tools._to_unicode, map(str.lower, ( 'AccelDir', 'AccelName', 'DataDirectory', @@ -344,7 +344,7 @@ IMMUTABLE_CONFIG_OPTIONS = map(str.lower, ( 'SyslogIdentityTag', 'TokenBucketRefillInterval', 'User', -)) +))))
LOG_CACHE_FETCHES = True # provide trace level logging for cache hits
@@ -2398,7 +2398,7 @@ class Controller(BaseController): self._set_cache({'get_custom_options': None}) else: log.debug('%s (failed, code: %s, message: %s)' % (query, response.code, response.message)) - immutable_params = [k for k, v in params if k.lower() in IMMUTABLE_CONFIG_OPTIONS] + immutable_params = [k for k, v in params if stem.util.str_tools._to_unicode(k).lower() in IMMUTABLE_CONFIG_OPTIONS]
if immutable_params: raise stem.InvalidArguments(message = "%s cannot be changed while tor's running" % ', '.join(sorted(immutable_params)), arguments = immutable_params)