From 61544504949b1d86d8919da98090c2f43390ef2a Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Mon, 8 Aug 2016 16:49:39 +0900 Subject: [PATCH] stringify: Fix to utilise six.moves.builtins To improve Pylint results, this patch fixes to utilise six.moves.builtins instead of using __builtin__ on Python2 or builtins on Python3. Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/stringify.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ryu/lib/stringify.py b/ryu/lib/stringify.py index 8fb2c967..21b0d9de 100644 --- a/ryu/lib/stringify.py +++ b/ryu/lib/stringify.py @@ -21,10 +21,10 @@ from __future__ import print_function import base64 import collections import inspect + import six - -# Some arguments to __init__ is mungled in order to avoid name conflicts +# Some arguments to __init__ is mangled in order to avoid name conflicts # with builtin names. # The standard mangling is to append '_' in order to avoid name clashes # with reserved keywords. @@ -40,15 +40,8 @@ import six # grep __init__ *.py | grep '[^_]_\>' showed that # 'len', 'property', 'set', 'type' # A bit more generic way is adopted -try: - # Python 2 - import __builtin__ -except ImportError: - # Python 3 - import builtins as __builtin__ - -_RESERVED_KEYWORD = dir(__builtin__) +_RESERVED_KEYWORD = dir(six.moves.builtins) _mapdict = lambda f, d: dict([(k, f(v)) for k, v in d.items()]) _mapdict_key = lambda f, d: dict([(f(k), v) for k, v in d.items()])