Unify different names between Python2/3 with six.moves
Some modules use different names in Python2 and Python3. Use six.moves to make them work well in Python2 and Python3. This is changes mapping: six.moves Python 2 Python 3 builtins __builtin__ builtins filter itertools.ifilter() filter() reduce reduce() functools.reduce() reload_module reload() imp.reload() Implements: blueprint make-python3-compatible Change-Id: I97971f2ab40385bfc2c73ae7e8a7620c4d64a03c
This commit is contained in:
parent
f47287fc64
commit
8c5e55f952
@ -349,7 +349,7 @@ class JSONFormatter(logging.Formatter):
|
||||
def formatException(self, ei, strip_newlines=True):
|
||||
lines = traceback.format_exception(*ei)
|
||||
if strip_newlines:
|
||||
lines = [itertools.ifilter(
|
||||
lines = [moves.filter(
|
||||
lambda x: x,
|
||||
line.rstrip().splitlines()) for line in lines]
|
||||
lines = list(itertools.chain(*lines))
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
import threading
|
||||
|
||||
from six import moves
|
||||
|
||||
from openstack.common import local
|
||||
from openstack.common import test
|
||||
|
||||
@ -36,7 +38,7 @@ class LocalStoreTestCase(test.BaseTestCase):
|
||||
# testing in (eventlet vs normal python threading) so
|
||||
# we test the correct type of local store for the current
|
||||
# threading model
|
||||
reload(local)
|
||||
moves.reload_module(local)
|
||||
|
||||
def test_thread_unique_storage(self):
|
||||
"""Make sure local store holds thread specific values."""
|
||||
|
Loading…
Reference in New Issue
Block a user