From e381f56197542349ea616f4f71e68b481f98247c Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Tue, 5 Nov 2013 16:19:16 +0600 Subject: Added six.moves.urllib.request.proxy_bypass --- six.py | 1 + 1 file changed, 1 insertion(+) diff --git a/six.py b/six.py index 176196c..aa6c4d5 100644 --- a/six.py +++ b/six.py @@ -284,6 +284,7 @@ _urllib_request_moved_attributes = [ MovedAttribute("urlcleanup", "urllib", "urllib.request"), MovedAttribute("URLopener", "urllib", "urllib.request"), MovedAttribute("FancyURLopener", "urllib", "urllib.request"), + MovedAttribute("proxy_bypass", "urllib", "urllib.request"), ] for attr in _urllib_request_moved_attributes: setattr(Module_six_moves_urllib_request, attr.name, attr) -- cgit v1.2.1 From facf96b253205d58d46fe6ea780a81c2c7203d26 Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Thu, 7 Nov 2013 14:45:15 +0600 Subject: fixed six.u('\\\\') in Python 2 --- six.py | 5 ++++- test_six.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/six.py b/six.py index 176196c..729ba7a 100644 --- a/six.py +++ b/six.py @@ -21,6 +21,7 @@ # SOFTWARE. import operator +import re import sys import types @@ -467,8 +468,10 @@ if PY3: else: def b(s): return s + # Workaround for standalone backslash + _U = re.compile(r'\\(?!u)') def u(s): - return unicode(s, "unicode_escape") + return unicode(_U.sub('\\u005C', s), "unicode_escape") unichr = unichr int2byte = chr def byte2int(bs): diff --git a/test_six.py b/test_six.py index efeb33e..e233e97 100644 --- a/test_six.py +++ b/test_six.py @@ -385,9 +385,9 @@ if six.PY3: def test_u(): - s = six.u("hi") + s = six.u("hi \u0439 \\ \\\\ \n") assert isinstance(s, str) - assert s == "hi" + assert s == "hi \u0439 \\ \\\\ \n" else: @@ -399,9 +399,9 @@ else: def test_u(): - s = six.u("hi") + s = six.u("hi \u0439 \\ \\\\ \n") assert isinstance(s, unicode) - assert s == "hi" + assert s == "hi \xd0\xb9 \\ \\\\ \n".decode("utf8") def test_u_escapes(): -- cgit v1.2.1 From cd94ad1bb887ca30b5019d69df9a31e496a8af2f Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Wed, 27 Nov 2013 19:55:25 +0600 Subject: documentation: proxy_bypass --- documentation/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/index.rst b/documentation/index.rst index ee8b60d..394fb9c 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -617,6 +617,7 @@ Contains items from Python 3's :mod:`py3:urllib.request` and Python 2's: * :func:`py2:urllib.urlcleanup` * :class:`py2:urllib.URLopener` * :class:`py2:urllib.FancyURLopener` +* :func:`py2:urllib.proxy_bypass` and :mod:`py2:urllib2`: -- cgit v1.2.1 From 23a3d2d504c1875d5eba8cc0abab3b127714c533 Mon Sep 17 00:00:00 2001 From: alexanderlukanin13 Date: Wed, 27 Nov 2013 20:10:54 +0600 Subject: six.u 4-byte unicode escaping fixed ('\U00000439') --- six.py | 2 +- test_six.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/six.py b/six.py index 729ba7a..e4c0da4 100644 --- a/six.py +++ b/six.py @@ -469,7 +469,7 @@ else: def b(s): return s # Workaround for standalone backslash - _U = re.compile(r'\\(?!u)') + _U = re.compile(r'\\(?![uU])') def u(s): return unicode(_U.sub('\\u005C', s), "unicode_escape") unichr = unichr diff --git a/test_six.py b/test_six.py index e233e97..94e33eb 100644 --- a/test_six.py +++ b/test_six.py @@ -385,9 +385,9 @@ if six.PY3: def test_u(): - s = six.u("hi \u0439 \\ \\\\ \n") + s = six.u("hi \u0439 \U00000439 \\ \\\\ \n") assert isinstance(s, str) - assert s == "hi \u0439 \\ \\\\ \n" + assert s == "hi \u0439 \U00000439 \\ \\\\ \n" else: @@ -399,9 +399,9 @@ else: def test_u(): - s = six.u("hi \u0439 \\ \\\\ \n") + s = six.u("hi \u0439 \U00000439 \\ \\\\ \n") assert isinstance(s, unicode) - assert s == "hi \xd0\xb9 \\ \\\\ \n".decode("utf8") + assert s == "hi \xd0\xb9 \xd0\xb9 \\ \\\\ \n".decode("utf8") def test_u_escapes(): -- cgit v1.2.1 -- cgit v1.2.1 From 8f78eb74ad7e9e4e304f60e5eb17f4e29635b7c4 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 27 Nov 2013 11:12:34 -0600 Subject: update changelog for pr #21 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 6ef6813..1e9eec5 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ This file lists the changes in each six version. Development version ------------------- +- Pull request #21: Add import mapping for urllib's proxy_bypass function. + - Issue #43: Add import mapping for the Python 2 xmlrpclib module. - Issue #39: Add import mapping for the Python 2 thread module. -- cgit v1.2.1 -- cgit v1.2.1 From 50e2f4f7338a05ce6e538e47f616794d37f93722 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 9 Dec 2013 06:46:57 -0800 Subject: Test that dir() returns attributes, despite lazy loading --- test_six.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_six.py b/test_six.py index efeb33e..7b62e53 100644 --- a/test_six.py +++ b/test_six.py @@ -99,6 +99,7 @@ def test_move_items(item_name): if item_name.startswith("tkinter") and not have_tkinter: py.test.skip("requires tkinter") raise + assert item_name in dir(six.moves) @py.test.mark.parametrize("item_name", @@ -109,6 +110,7 @@ def test_move_items_urllib_parse(item_name): py.test.skip("ParseResult is only found on 2.5+") if item_name in ("parse_qs", "parse_qsl") and sys.version_info < (2, 6): py.test.skip("parse_qs[l] is new in 2.6") + assert item_name in dir(six.moves.urllib.parse) getattr(six.moves.urllib.parse, item_name) @@ -116,6 +118,7 @@ def test_move_items_urllib_parse(item_name): [item.name for item in six._urllib_error_moved_attributes]) def test_move_items_urllib_error(item_name): """Ensure that everything loads correctly.""" + assert item_name in dir(six.moves.urllib.error) getattr(six.moves.urllib.error, item_name) @@ -123,6 +126,7 @@ def test_move_items_urllib_error(item_name): [item.name for item in six._urllib_request_moved_attributes]) def test_move_items_urllib_request(item_name): """Ensure that everything loads correctly.""" + assert item_name in dir(six.moves.urllib.request) getattr(six.moves.urllib.request, item_name) @@ -130,6 +134,7 @@ def test_move_items_urllib_request(item_name): [item.name for item in six._urllib_response_moved_attributes]) def test_move_items_urllib_response(item_name): """Ensure that everything loads correctly.""" + assert item_name in dir(six.moves.urllib.response) getattr(six.moves.urllib.response, item_name) @@ -137,6 +142,7 @@ def test_move_items_urllib_response(item_name): [item.name for item in six._urllib_robotparser_moved_attributes]) def test_move_items_urllib_robotparser(item_name): """Ensure that everything loads correctly.""" + assert item_name in dir(six.moves.urllib.robotparser) getattr(six.moves.urllib.robotparser, item_name) -- cgit v1.2.1 From 6a8540652cc07777eb3770f5dc18709ff1e31344 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 9 Dec 2013 06:47:25 -0800 Subject: Make dir() return attributes, despite lazy loading --- six.py | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/six.py b/six.py index aa6c4d5..999faa6 100644 --- a/six.py +++ b/six.py @@ -105,6 +105,21 @@ class MovedModule(_LazyDescr): return _import_module(self.mod) +class LazyModule(types.ModuleType): + + def __init__(self, name): + super(LazyModule, self).__init__(name) + self.__doc__ = self.__class__.__doc__ + + def __dir__(self): + attrs = ["__doc__", "__name__"] + attrs += [attr.name for attr in self._moved_attributes] + return attrs + + # Subclasses should override this + _moved_attributes = [] + + class MovedAttribute(_LazyDescr): def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): @@ -131,7 +146,7 @@ class MovedAttribute(_LazyDescr): -class _MovedItems(types.ModuleType): +class _MovedItems(LazyModule): """Lazy loading of moved objects""" @@ -198,11 +213,13 @@ for attr in _moved_attributes: setattr(_MovedItems, attr.name, attr) del attr +_MovedItems._moved_attributes = _moved_attributes + moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") -class Module_six_moves_urllib_parse(types.ModuleType): +class Module_six_moves_urllib_parse(LazyModule): """Lazy loading of moved objects in six.moves.urllib_parse""" @@ -226,11 +243,13 @@ for attr in _urllib_parse_moved_attributes: setattr(Module_six_moves_urllib_parse, attr.name, attr) del attr +Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes + sys.modules[__name__ + ".moves.urllib_parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse") sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib.parse") -class Module_six_moves_urllib_error(types.ModuleType): +class Module_six_moves_urllib_error(LazyModule): """Lazy loading of moved objects in six.moves.urllib_error""" @@ -243,11 +262,13 @@ for attr in _urllib_error_moved_attributes: setattr(Module_six_moves_urllib_error, attr.name, attr) del attr +Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes + sys.modules[__name__ + ".moves.urllib_error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib_error") sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error") -class Module_six_moves_urllib_request(types.ModuleType): +class Module_six_moves_urllib_request(LazyModule): """Lazy loading of moved objects in six.moves.urllib_request""" @@ -290,11 +311,13 @@ for attr in _urllib_request_moved_attributes: setattr(Module_six_moves_urllib_request, attr.name, attr) del attr +Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes + sys.modules[__name__ + ".moves.urllib_request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib_request") sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request") -class Module_six_moves_urllib_response(types.ModuleType): +class Module_six_moves_urllib_response(LazyModule): """Lazy loading of moved objects in six.moves.urllib_response""" @@ -308,11 +331,13 @@ for attr in _urllib_response_moved_attributes: setattr(Module_six_moves_urllib_response, attr.name, attr) del attr +Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes + sys.modules[__name__ + ".moves.urllib_response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib_response") sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response") -class Module_six_moves_urllib_robotparser(types.ModuleType): +class Module_six_moves_urllib_robotparser(LazyModule): """Lazy loading of moved objects in six.moves.urllib_robotparser""" @@ -323,6 +348,8 @@ for attr in _urllib_robotparser_moved_attributes: setattr(Module_six_moves_urllib_robotparser, attr.name, attr) del attr +Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes + sys.modules[__name__ + ".moves.urllib_robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib_robotparser") sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser") @@ -335,6 +362,9 @@ class Module_six_moves_urllib(types.ModuleType): response = sys.modules[__name__ + ".moves.urllib_response"] robotparser = sys.modules[__name__ + ".moves.urllib_robotparser"] + def __dir__(self): + return ['parse', 'error', 'request', 'response', 'robotparser'] + sys.modules[__name__ + ".moves.urllib"] = Module_six_moves_urllib(__name__ + ".moves.urllib") -- cgit v1.2.1 From 617ae7ce0a7f04790b89aec4014a0d75fc14889b Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 21:53:44 -0600 Subject: add change note for issue #44 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 1e9eec5..19d3843 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ This file lists the changes in each six version. Development version ------------------- +- Issue #44: Fix interpretation of backslashes on Python 2 in the u() function. + - Pull request #21: Add import mapping for urllib's proxy_bypass function. - Issue #43: Add import mapping for the Python 2 xmlrpclib module. -- cgit v1.2.1 From cff44f7829291fb4605d47ce4a9c33c5eee5ead6 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 21:53:58 -0600 Subject: use replace instead regular expression --- six.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/six.py b/six.py index de2e94f..f782f9a 100644 --- a/six.py +++ b/six.py @@ -21,7 +21,6 @@ # SOFTWARE. import operator -import re import sys import types @@ -470,9 +469,8 @@ else: def b(s): return s # Workaround for standalone backslash - _U = re.compile(r'\\(?![uU])') def u(s): - return unicode(_U.sub('\\u005C', s), "unicode_escape") + return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") unichr = unichr int2byte = chr def byte2int(bs): -- cgit v1.2.1 From 99e86b18cb2096a1293b93db7c3bd2a951d6f848 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 21:59:17 -0600 Subject: remove support for Python 2.4, since py.test doesn't support it anymore --- README | 2 +- documentation/index.rst | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README b/README index 99bd3a6..4de73fa 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ for smoothing over the differences between the Python versions with the goal of writing Python code that is compatible on both Python versions. See the documentation for more information on what is provided. -Six supports every Python version since 2.4. It is contained in only one Python +Six supports every Python version since 2.5. It is contained in only one Python file, so it can be easily copied into your project. (The copyright and license notice must be retained.) diff --git a/documentation/index.rst b/documentation/index.rst index 394fb9c..5c7860d 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -137,27 +137,26 @@ functions and methods is the stdlib :mod:`py3:inspect` module. Get the closure (list of cells) associated with *func*. This is equivalent to ``func.__closure__`` on Python 2.6+ and ``func.func_closure`` on Python - 2.4 and 2.5. + 2.5. .. function:: get_function_code(func) Get the code object associated with *func*. This is equivalent to - ``func.__code__`` on Python 2.6+ and ``func.func_code`` on Python 2.4 and - 2.5. + ``func.__code__`` on Python 2.6+ and ``func.func_code`` on Python 2.5. .. function:: get_function_defaults(func) Get the defaults tuple associated with *func*. This is equivalent to - ``func.__defaults__`` on Python 2.6+ and ``func.func_defaults`` on Python 2.4 - and 2.5. + ``func.__defaults__`` on Python 2.6+ and ``func.func_defaults`` on Python + 2.5. .. function:: get_function_globals(func) Get the globals of *func*. This is equivalent to ``func.__globals__`` on - Python 2.6+ and ``func.func_globals`` on Python 2.4 and 2.5. + Python 2.6+ and ``func.func_globals`` on Python 2.5. .. function:: next(it) @@ -307,7 +306,7 @@ Python 2 and 3. on Python 2. Note that class decorators require Python 2.6. However, the effect of the - decorator can be emulated on Python 2.4 and 2.5 like so:: + decorator can be emulated on Python 2.5 like so:: class MyClass(object): pass -- cgit v1.2.1 From 4ba1d2432cbb5217226194b5a3941c6de01fef6e Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 22:11:40 -0600 Subject: adjust comment --- test_six.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_six.py b/test_six.py index 94e33eb..81b424f 100644 --- a/test_six.py +++ b/test_six.py @@ -621,7 +621,7 @@ def test_add_metaclass(): assert instance.b == Base.b assert instance.x == X.x - # test a class with slots + # Test a class with slots. class MySlots(object): __slots__ = ["a", "b"] MySlots = six.add_metaclass(Meta1)(MySlots) -- cgit v1.2.1 From 54e88aec5f7156dd6dcd440abb5b7e81cdb38ca5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 20 Dec 2013 22:14:45 -0600 Subject: fix add_metaclass when __slots__ is a string (fixes #47) --- CHANGES | 3 +++ six.py | 8 ++++++-- test_six.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 19d3843..6aca0dd 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ This file lists the changes in each six version. Development version ------------------- +- Issue #47: Fix add_metaclass on classes with a string for the __slots__ + variable. + - Issue #44: Fix interpretation of backslashes on Python 2 in the u() function. - Pull request #21: Add import mapping for urllib's proxy_bypass function. diff --git a/six.py b/six.py index f782f9a..a0eea9a 100644 --- a/six.py +++ b/six.py @@ -581,7 +581,11 @@ def add_metaclass(metaclass): orig_vars = cls.__dict__.copy() orig_vars.pop('__dict__', None) orig_vars.pop('__weakref__', None) - for slots_var in orig_vars.get('__slots__', ()): - orig_vars.pop(slots_var) + slots = orig_vars.get('__slots__') + if slots is not None: + if isinstance(slots, str): + slots = [slots] + for slots_var in slots: + orig_vars.pop(slots_var) return metaclass(cls.__name__, cls.__bases__, orig_vars) return wrapper diff --git a/test_six.py b/test_six.py index 81b424f..7f92617 100644 --- a/test_six.py +++ b/test_six.py @@ -630,3 +630,14 @@ def test_add_metaclass(): instance = MySlots() instance.a = "foo" py.test.raises(AttributeError, setattr, instance, "c", "baz") + + # Test a class with string for slots. + class MyStringSlots(object): + __slots__ = "ab" + MyStringSlots = six.add_metaclass(Meta1)(MyStringSlots) + assert MyStringSlots.__slots__ == "ab" + instance = MyStringSlots() + instance.ab = "foo" + py.test.raises(AttributeError, setattr, instance, "a", "baz") + py.test.raises(AttributeError, setattr, instance, "b", "baz") + -- cgit v1.2.1 From d8af256db43d1157d197658f760fedc69ca91ca9 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 25 Dec 2013 14:37:27 -0800 Subject: test_six.py: Don't check dir on python < 2.6 because pythons < 2.6 did not have __dir__ method --- test_six.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test_six.py b/test_six.py index 7b62e53..91dfdf3 100644 --- a/test_six.py +++ b/test_six.py @@ -110,7 +110,8 @@ def test_move_items_urllib_parse(item_name): py.test.skip("ParseResult is only found on 2.5+") if item_name in ("parse_qs", "parse_qsl") and sys.version_info < (2, 6): py.test.skip("parse_qs[l] is new in 2.6") - assert item_name in dir(six.moves.urllib.parse) + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.parse) getattr(six.moves.urllib.parse, item_name) @@ -118,7 +119,8 @@ def test_move_items_urllib_parse(item_name): [item.name for item in six._urllib_error_moved_attributes]) def test_move_items_urllib_error(item_name): """Ensure that everything loads correctly.""" - assert item_name in dir(six.moves.urllib.error) + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.error) getattr(six.moves.urllib.error, item_name) @@ -126,7 +128,8 @@ def test_move_items_urllib_error(item_name): [item.name for item in six._urllib_request_moved_attributes]) def test_move_items_urllib_request(item_name): """Ensure that everything loads correctly.""" - assert item_name in dir(six.moves.urllib.request) + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.request) getattr(six.moves.urllib.request, item_name) @@ -134,7 +137,8 @@ def test_move_items_urllib_request(item_name): [item.name for item in six._urllib_response_moved_attributes]) def test_move_items_urllib_response(item_name): """Ensure that everything loads correctly.""" - assert item_name in dir(six.moves.urllib.response) + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.response) getattr(six.moves.urllib.response, item_name) @@ -142,7 +146,8 @@ def test_move_items_urllib_response(item_name): [item.name for item in six._urllib_robotparser_moved_attributes]) def test_move_items_urllib_robotparser(item_name): """Ensure that everything loads correctly.""" - assert item_name in dir(six.moves.urllib.robotparser) + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.robotparser) getattr(six.moves.urllib.robotparser, item_name) -- cgit v1.2.1 From 1fefc695f8cdb3f317b27171df135af9b683ea12 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 25 Dec 2013 14:38:49 -0800 Subject: Rename LazyModule to _LazyModule to reflect private nature --- six.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/six.py b/six.py index 999faa6..8d0205e 100644 --- a/six.py +++ b/six.py @@ -105,10 +105,10 @@ class MovedModule(_LazyDescr): return _import_module(self.mod) -class LazyModule(types.ModuleType): +class _LazyModule(types.ModuleType): def __init__(self, name): - super(LazyModule, self).__init__(name) + super(_LazyModule, self).__init__(name) self.__doc__ = self.__class__.__doc__ def __dir__(self): @@ -146,7 +146,7 @@ class MovedAttribute(_LazyDescr): -class _MovedItems(LazyModule): +class _MovedItems(_LazyModule): """Lazy loading of moved objects""" @@ -219,7 +219,7 @@ moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") -class Module_six_moves_urllib_parse(LazyModule): +class Module_six_moves_urllib_parse(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_parse""" @@ -249,7 +249,7 @@ sys.modules[__name__ + ".moves.urllib_parse"] = Module_six_moves_urllib_parse(__ sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib.parse") -class Module_six_moves_urllib_error(LazyModule): +class Module_six_moves_urllib_error(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_error""" @@ -268,7 +268,7 @@ sys.modules[__name__ + ".moves.urllib_error"] = Module_six_moves_urllib_error(__ sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error") -class Module_six_moves_urllib_request(LazyModule): +class Module_six_moves_urllib_request(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_request""" @@ -317,7 +317,7 @@ sys.modules[__name__ + ".moves.urllib_request"] = Module_six_moves_urllib_reques sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request") -class Module_six_moves_urllib_response(LazyModule): +class Module_six_moves_urllib_response(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_response""" @@ -337,7 +337,7 @@ sys.modules[__name__ + ".moves.urllib_response"] = Module_six_moves_urllib_respo sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response") -class Module_six_moves_urllib_robotparser(LazyModule): +class Module_six_moves_urllib_robotparser(_LazyModule): """Lazy loading of moved objects in six.moves.urllib_robotparser""" -- cgit v1.2.1 From 3ed7bdb0af69fe162bd5c05795d8977905f337b3 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 25 Dec 2013 20:32:44 -0800 Subject: Don't fail test if gdbm is not available --- test_six.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test_six.py b/test_six.py index efeb33e..fee58e2 100644 --- a/test_six.py +++ b/test_six.py @@ -84,6 +84,15 @@ except ImportError: else: have_tkinter = True +have_gdbm = True +try: + import gdbm +except ImportError: + try: + import dbm.gnu + except ImportError: + have_gdbm = False + @py.test.mark.parametrize("item_name", [item.name for item in six._moved_attributes]) def test_move_items(item_name): @@ -98,6 +107,8 @@ def test_move_items(item_name): py.test.skip("Windows only module") if item_name.startswith("tkinter") and not have_tkinter: py.test.skip("requires tkinter") + if item_name.startswith("dbm_gnu") and not have_gdbm: + py.test.skip("requires gdbm") raise -- cgit v1.2.1 From 6de380126ab7f3add2ec36cfdbaf2dd82289c649 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 25 Dec 2013 23:25:49 -0600 Subject: changelog --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 6aca0dd..e6f7b4e 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ This file lists the changes in each six version. Development version ------------------- +- Pull request #24: Add __dir__ special method to six.moves modules. + - Issue #47: Fix add_metaclass on classes with a string for the __slots__ variable. -- cgit v1.2.1 From 98d9ceede87e1d13705e50d918391d2583868f6d Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Thu, 26 Dec 2013 09:10:36 -0800 Subject: test_six.py: test_MAXSIZE allow ValueError or OverflowError because the previous code was expecting ValueError on Python 2.4, but I was getting OverflowError on Python 2.4.4 on OS X but ValueError on Python 2.4.6 on Ubuntu. So perhaps knowing which exception will be raised is not that straightforward, so I made it check for either one. --- test_six.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test_six.py b/test_six.py index 34613ad..db9b624 100644 --- a/test_six.py +++ b/test_six.py @@ -59,11 +59,9 @@ def test_MAXSIZE(): except AttributeError: # Before Python 2.6. pass - if sys.version_info[:2] == (2, 4): - exc = ValueError - else: - exc = OverflowError - py.test.raises(exc, operator.mul, [None], six.MAXSIZE + 1) + py.test.raises( + (ValueError, OverflowError), + operator.mul, [None], six.MAXSIZE + 1) def test_lazy(): -- cgit v1.2.1 From 0d43663dab3af4de18ab98fbdb33168e6e0e19cc Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 4 Jan 2014 10:09:57 -0600 Subject: add mapping for ttk (fixes #49) --- CHANGES | 2 ++ documentation/index.rst | 4 +++- six.py | 1 + test_six.py | 7 +++++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index e6f7b4e..de20c4c 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,8 @@ This file lists the changes in each six version. Development version ------------------- +- Issue #49: Add six.moves mapping for tkinter.ttk. + - Pull request #24: Add __dir__ special method to six.moves modules. - Issue #47: Fix add_metaclass on classes with a string for the __slots__ diff --git a/documentation/index.rst b/documentation/index.rst index 5c7860d..57a0854 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -505,10 +505,12 @@ Supported renames: +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3:tkinter.FileDialog` | +------------------------------+-------------------------------------+-------------------------------------+ -| ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scrolledtext` | +| ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scrolledtext` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py2:tkinter.simpledialog` | +------------------------------+-------------------------------------+-------------------------------------+ +| ``tkiner_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` | ++------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_constants`` | :mod:`py2:Tkconstants` | :mod:`py3:tkinter.constants` | diff --git a/six.py b/six.py index d197d00..3fe5198 100644 --- a/six.py +++ b/six.py @@ -191,6 +191,7 @@ _moved_attributes = [ MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), MovedModule("tkinter_tix", "Tix", "tkinter.tix"), + MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), MovedModule("tkinter_colorchooser", "tkColorChooser", diff --git a/test_six.py b/test_six.py index db9b624..8815ee1 100644 --- a/test_six.py +++ b/test_six.py @@ -103,8 +103,11 @@ def test_move_items(item_name): except ImportError: if item_name == "winreg" and not sys.platform.startswith("win"): py.test.skip("Windows only module") - if item_name.startswith("tkinter") and not have_tkinter: - py.test.skip("requires tkinter") + if item_name.startswith("tkinter"): + if not have_tkinter: + py.test.skip("requires tkinter") + if item_name == "tkinter_ttk" and sys.version_info <= (2, 6): + py.test.skip("ttk only available on 2.7+") if item_name.startswith("dbm_gnu") and not have_gdbm: py.test.skip("requires gdbm") raise -- cgit v1.2.1 From e80bfe44f4a520733cd5981a23cdc320464f0f44 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 4 Jan 2014 10:10:24 -0600 Subject: fix role --- documentation/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.rst b/documentation/index.rst index 57a0854..c6ca808 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -507,7 +507,7 @@ Supported renames: +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scrolledtext` | +------------------------------+-------------------------------------+-------------------------------------+ -| ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py2:tkinter.simpledialog` | +| ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py3:tkinter.simpledialog` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkiner_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` | +------------------------------+-------------------------------------+-------------------------------------+ -- cgit v1.2.1 From d875c72240219a0ba7f390003939bdabd5baf1a1 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sat, 4 Jan 2014 10:18:47 -0800 Subject: documentation/index.rst: Fix typo: "tkiner" -> "tkinter" --- documentation/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.rst b/documentation/index.rst index c6ca808..1bd327a 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -509,7 +509,7 @@ Supported renames: +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py3:tkinter.simpledialog` | +------------------------------+-------------------------------------+-------------------------------------+ -| ``tkiner_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` | +| ``tkinter_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` | +------------------------------+-------------------------------------+-------------------------------------+ -- cgit v1.2.1