diff options
author | Victor Stinner <vstinner@redhat.com> | 2015-10-09 16:16:31 +0200 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2015-10-12 10:07:53 +0200 |
commit | 6f424f73cd340d1d6edd018de373430ca03712a6 (patch) | |
tree | e7c1bbb3131a49f3498346a9d13fbef48f0216b6 /oslo_rootwrap/wrapper.py | |
parent | 38e738e3139c496d4c711b39995ddc6b46a70d92 (diff) | |
download | oslo-rootwrap-6f424f73cd340d1d6edd018de373430ca03712a6.tar.gz |
Fix Python 3 issues in tests
* get StringIO from six.StringIO to support Python 2 and Python 3
* Replace "__builtin__.open" with "six.moves.builtins.open" to mock
open()
* Workaround a Python 3.4.0 regression: get the log level directly
from logging._nameToLevel instead of using logging.getLevelName().
Replace Python 3.3 with Python 3.4:
* tox.ini: replace py33 test environment with py34
* setup.cfg: replace "Programming Language :: Python :: 3.3"
classifier with "Programming Language :: Python :: 3.4"
Change-Id: Ied495f5867f47eee57b64ab35c0423913ee17d6e
Diffstat (limited to 'oslo_rootwrap/wrapper.py')
-rw-r--r-- | oslo_rootwrap/wrapper.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/oslo_rootwrap/wrapper.py b/oslo_rootwrap/wrapper.py index 996b8f9..98f0729 100644 --- a/oslo_rootwrap/wrapper.py +++ b/oslo_rootwrap/wrapper.py @@ -68,9 +68,16 @@ class RootwrapConfig(object): # syslog_log_level if config.has_option("DEFAULT", "syslog_log_level"): v = config.get("DEFAULT", "syslog_log_level") - self.syslog_log_level = logging.getLevelName(v.upper()) - if (self.syslog_log_level == "Level %s" % v.upper()): - raise ValueError('Unexpected syslog_log_level: %s' % v) + level = v.upper() + if (hasattr(logging, '_nameToLevel') + and level in logging._nameToLevel): + # Workaround a regression of Python 3.4.0 bug fixed in 3.4.2: + # http://bugs.python.org/issue22386 + self.syslog_log_level = logging._nameToLevel[level] + else: + self.syslog_log_level = logging.getLevelName(level) + if (self.syslog_log_level == "Level %s" % level): + raise ValueError('Unexpected syslog_log_level: %r' % v) else: self.syslog_log_level = logging.ERROR |