diff -Nru six-1.4.1/CHANGES six-1.5.2/CHANGES --- six-1.4.1/CHANGES 2013-09-02 13:09:15.000000000 +0000 +++ six-1.5.2/CHANGES 2014-01-06 15:53:20.000000000 +0000 @@ -3,6 +3,48 @@ This file lists the changes in each six version. +1.5.2 +----- + +- Issue #53: Make the fake modules six.moves puts into sys.modules appear not to + have a __name__ unless they are loaded. + +1.5.1 +----- + +- Issue #51: Hack around the Django autoreloader after recent six.moves changes. + +1.5.0 +----- + +- Removed support for Python 2.4. This is because py.test no longer supports + 2.4. + +- Fix various import problems including issues #19 and #41. six.moves modules + are now lazy wrappers over the underlying modules instead of the actual + modules themselves. + +- 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__ + 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. + +- Issue #43: Add import mapping for the Python 2 xmlrpclib module. + +- Issue #39: Add import mapping for the Python 2 thread module. + +- Issue #40: Add import mapping for the Python 2 gdbm module. + +- Issue #35: On Python versions less than 2.7, print_ now encodes unicode + strings when outputing to standard streams. (Python 2.7 handles this + automatically.) + 1.4.1 ----- diff -Nru six-1.4.1/LICENSE six-1.5.2/LICENSE --- six-1.4.1/LICENSE 2013-03-17 04:09:50.000000000 +0000 +++ six-1.5.2/LICENSE 2014-01-04 22:36:04.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright (c) 2010-2013 Benjamin Peterson +Copyright (c) 2010-2014 Benjamin Peterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff -Nru six-1.4.1/MANIFEST.in six-1.5.2/MANIFEST.in --- six-1.4.1/MANIFEST.in 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/MANIFEST.in 2012-08-28 20:05:33.000000000 +0000 @@ -0,0 +1,6 @@ +include CHANGES +include LICENSE +include test_six.py + +recursive-include documentation * +prune documentation/_build diff -Nru six-1.4.1/PKG-INFO six-1.5.2/PKG-INFO --- six-1.4.1/PKG-INFO 2013-09-02 13:11:53.000000000 +0000 +++ six-1.5.2/PKG-INFO 2014-01-06 15:57:41.000000000 +0000 @@ -1,17 +1,17 @@ Metadata-Version: 1.1 Name: six -Version: 1.4.1 +Version: 1.5.2 Summary: Python 2 and 3 compatibility utilities Home-page: http://pypi.python.org/pypi/six/ Author: Benjamin Peterson Author-email: benjamin@python.org -License: UNKNOWN +License: MIT Description: Six is a Python 2 and 3 compatibility library. It provides utility functions 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 -Nru six-1.4.1/README six-1.5.2/README --- six-1.4.1/README 2013-06-03 04:55:09.000000000 +0000 +++ six-1.5.2/README 2013-12-21 03:57:59.000000000 +0000 @@ -3,7 +3,7 @@ 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 -Nru six-1.4.1/debian/changelog six-1.5.2/debian/changelog --- six-1.4.1/debian/changelog 2013-12-02 12:19:03.000000000 +0000 +++ six-1.5.2/debian/changelog 2014-01-12 05:05:15.000000000 +0000 @@ -1,8 +1,16 @@ -six (1.4.1-1~ubuntu12.04.1~icehouse0) precise; urgency=low +six (1.5.2-1~cloud0) precise-icehouse; urgency=low - * No-change backport to precise + * New upstream release for the Ubuntu Cloud Archive. - -- Openstack Ubuntu Testing Bot Mon, 02 Dec 2013 07:19:03 -0500 + -- Openstack Ubuntu Testing Bot Sun, 12 Jan 2014 00:05:15 -0500 + +six (1.5.2-1) unstable; urgency=medium + + * New upstream release. + * Switch to git; adjust Vcs-* fields. + * Policy version 3.9.5: no changes required. + + -- Colin Watson Tue, 07 Jan 2014 01:00:45 +0000 six (1.4.1-1) unstable; urgency=low diff -Nru six-1.4.1/debian/control six-1.5.2/debian/control --- six-1.4.1/debian/control 2013-09-04 05:42:44.000000000 +0000 +++ six-1.5.2/debian/control 2014-01-07 01:00:21.000000000 +0000 @@ -2,10 +2,12 @@ Section: python Priority: optional Maintainer: Colin Watson -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Build-Depends: debhelper (>= 7.2.11~), python (>= 2.6.6-3~), python-all, python3 (>= 3.1.2-8~), python3-all, python-pytest, python3-pytest Homepage: http://pythonhosted.org/six/ -X-Python-Version: >= 2.4 +Vcs-Git: git://anonscm.debian.org/users/cjwatson/six.git +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=users/cjwatson/six.git +X-Python-Version: >= 2.5 X-Python3-Version: >= 3.0 Package: python-six diff -Nru six-1.4.1/debian/copyright six-1.5.2/debian/copyright --- six-1.4.1/debian/copyright 2013-04-27 11:30:41.000000000 +0000 +++ six-1.5.2/debian/copyright 2014-01-07 00:46:42.000000000 +0000 @@ -3,7 +3,7 @@ Source: http://pypi.python.org/pypi/six/ Files: * -Copyright: Copyright (c) 2010-2013 Benjamin Peterson +Copyright: Copyright (c) 2010-2014 Benjamin Peterson License: Expat Files: debian/* diff -Nru six-1.4.1/documentation/conf.py six-1.5.2/documentation/conf.py --- six-1.4.1/documentation/conf.py 2012-05-20 06:35:39.000000000 +0000 +++ six-1.5.2/documentation/conf.py 2013-09-15 13:52:34.000000000 +0000 @@ -213,5 +213,5 @@ # -- Intersphinx --------------------------------------------------------------- -intersphinx_mapping = {"py2" : ("http://docs.python.org/", None), - "py3" : ("http://docs.python.org/py3k/", None)} +intersphinx_mapping = {"py2" : ("http://docs.python.org/2/", None), + "py3" : ("http://docs.python.org/3/", None)} diff -Nru six-1.4.1/documentation/index.rst six-1.5.2/documentation/index.rst --- six-1.4.1/documentation/index.rst 2013-09-01 21:12:47.000000000 +0000 +++ six-1.5.2/documentation/index.rst 2014-01-04 18:22:33.000000000 +0000 @@ -17,8 +17,8 @@ tracker and code hosting is on `BitBucket `_. The name, "six", comes from the fact that 2*3 equals 6. Why not addition? -Multiplication is more powerful, and, anyway, "five" has already been `snatched -away `_. +Multiplication is more powerful, and, anyway, "five" has already been snatched +away by the Zope Five project. Indices and tables @@ -137,27 +137,26 @@ 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) @@ -243,10 +242,10 @@ :func:`exec` with them should be avoided. -.. function:: print_(*args, *, file=sys.stdout, end="\n", sep=" ") +.. function:: print_(*args, *, file=sys.stdout, end="\\n", sep=" ") Print *args* into *file*. Each argument will be separated with *sep* and - *end* will be written to the file at the last. + *end* will be written to the file after the last argument is printed. .. note:: @@ -307,7 +306,7 @@ 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 @@ -433,13 +432,11 @@ ``pickle``. In these cases, fetching the fast version will load the fast one on Python 2 and the merged module in Python 3. - -.. note:: - - The :mod:`py2:urllib`, :mod:`py2:urllib2`, and :mod:`py2:urlparse` modules - have been combined in the :mod:`py3:urllib` package in Python 3. - :mod:`six.moves` doesn't not support their renaming because their members - have been mixed across several modules in that package. +The :mod:`py2:urllib`, :mod:`py2:urllib2`, and :mod:`py2:urlparse` modules have +been combined in the :mod:`py3:urllib` package in Python 3. The +:mod:`six.moves.urllib` package is a version-independent location for this +functionality; its structure mimics the structure of the Python 3 +:mod:`py3:urllib` package. Supported renames: @@ -456,6 +453,8 @@ +------------------------------+-------------------------------------+-------------------------------------+ | ``cStringIO`` | :func:`py2:cStringIO.StringIO` | :class:`py3:io.StringIO` | +------------------------------+-------------------------------------+-------------------------------------+ +| ``dbm_gnu`` | :func:`py2:gdbm` | :class:`py3:dbm.gnu` | ++------------------------------+-------------------------------------+-------------------------------------+ | ``email_mime_multipart`` | :mod:`py2:email.MIMEMultipart` | :mod:`py3:email.mime.multipart` | +------------------------------+-------------------------------------+-------------------------------------+ | ``email_mime_text`` | :mod:`py2:email.MIMEText` | :mod:`py3:email.mime.text` | @@ -498,15 +497,19 @@ +------------------------------+-------------------------------------+-------------------------------------+ | ``socketserver`` | :mod:`py2:SocketServer` | :mod:`py3:socketserver` | +------------------------------+-------------------------------------+-------------------------------------+ +| ``_thread`` | :mod:`py2:thread` | :mod:`py3:_thread` | ++------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter`` | :mod:`py2:Tkinter` | :mod:`py3:tkinter` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_dialog`` | :mod:`py2:Dialog` | :mod:`py3:tkinter.dialog` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3:tkinter.FileDialog` | +------------------------------+-------------------------------------+-------------------------------------+ -| ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scolledtext` | +| ``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` | ++------------------------------+-------------------------------------+-------------------------------------+ +| ``tkinter_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` | +------------------------------+-------------------------------------+-------------------------------------+ | ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` | +------------------------------+-------------------------------------+-------------------------------------+ @@ -542,6 +545,8 @@ +------------------------------+-------------------------------------+-------------------------------------+ | ``winreg`` | :mod:`py2:_winreg` | :mod:`py3:winreg` | +------------------------------+-------------------------------------+-------------------------------------+ +| ``xmlrpc_client`` | :mod:`py2:xmlrpclib` | :mod:`py3:xmlrpclib` | ++------------------------------+-------------------------------------+-------------------------------------+ | ``xrange`` | :func:`py2:xrange` | :func:`py3:range` | +------------------------------+-------------------------------------+-------------------------------------+ | ``zip`` | :func:`py2:itertools.izip` | :func:`py3:zip` | @@ -559,6 +564,7 @@ :mod:`py2:urlparse`: +* :func:`py2:urlparse.ParseResult` * :func:`py2:urlparse.urlparse` * :func:`py2:urlparse.urlunparse` * :func:`py2:urlparse.parse_qs` @@ -612,6 +618,7 @@ * :func:`py2:urllib.urlcleanup` * :class:`py2:urllib.URLopener` * :class:`py2:urllib.FancyURLopener` +* :func:`py2:urllib.proxy_bypass` and :mod:`py2:urllib2`: diff -Nru six-1.4.1/setup.cfg six-1.5.2/setup.cfg --- six-1.4.1/setup.cfg 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/setup.cfg 2014-01-06 15:57:41.000000000 +0000 @@ -0,0 +1,8 @@ +[wheel] +universal = 1 + +[egg_info] +tag_date = 0 +tag_build = +tag_svn_revision = 0 + diff -Nru six-1.4.1/setup.py six-1.5.2/setup.py --- six-1.4.1/setup.py 2012-05-20 06:35:39.000000000 +0000 +++ six-1.5.2/setup.py 2014-01-05 05:35:26.000000000 +0000 @@ -1,4 +1,9 @@ -from distutils.core import setup +from __future__ import with_statement + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup import six @@ -11,12 +16,8 @@ "Topic :: Utilities", ] -fp = open("README", "r") -try: +with open("README", "r") as fp: six_long_description = fp.read() -finally: - fp.close() - setup(name="six", version=six.__version__, @@ -26,5 +27,6 @@ py_modules=["six"], description="Python 2 and 3 compatibility utilities", long_description=six_long_description, + license="MIT", classifiers=six_classifiers ) diff -Nru six-1.4.1/six.egg-info/PKG-INFO six-1.5.2/six.egg-info/PKG-INFO --- six-1.4.1/six.egg-info/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/six.egg-info/PKG-INFO 2014-01-06 15:57:40.000000000 +0000 @@ -0,0 +1,32 @@ +Metadata-Version: 1.1 +Name: six +Version: 1.5.2 +Summary: Python 2 and 3 compatibility utilities +Home-page: http://pypi.python.org/pypi/six/ +Author: Benjamin Peterson +Author-email: benjamin@python.org +License: MIT +Description: Six is a Python 2 and 3 compatibility library. It provides utility functions + 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.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.) + + Online documentation is at http://pythonhosted.org/six/. + + Bugs can be reported to http://bitbucket.org/gutworth/six. The code can also be + found there. + + For questions about six or porting in general, email the python-porting mailing + list: http://mail.python.org/mailman/listinfo/python-porting + +Platform: UNKNOWN +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 3 +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Topic :: Software Development :: Libraries +Classifier: Topic :: Utilities diff -Nru six-1.4.1/six.egg-info/SOURCES.txt six-1.5.2/six.egg-info/SOURCES.txt --- six-1.4.1/six.egg-info/SOURCES.txt 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/six.egg-info/SOURCES.txt 2014-01-06 15:57:41.000000000 +0000 @@ -0,0 +1,15 @@ +CHANGES +LICENSE +MANIFEST.in +README +setup.cfg +setup.py +six.py +test_six.py +documentation/Makefile +documentation/conf.py +documentation/index.rst +six.egg-info/PKG-INFO +six.egg-info/SOURCES.txt +six.egg-info/dependency_links.txt +six.egg-info/top_level.txt \ No newline at end of file diff -Nru six-1.4.1/six.egg-info/dependency_links.txt six-1.5.2/six.egg-info/dependency_links.txt --- six-1.4.1/six.egg-info/dependency_links.txt 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/six.egg-info/dependency_links.txt 2014-01-06 15:57:40.000000000 +0000 @@ -0,0 +1 @@ + diff -Nru six-1.4.1/six.egg-info/top_level.txt six-1.5.2/six.egg-info/top_level.txt --- six-1.4.1/six.egg-info/top_level.txt 1970-01-01 00:00:00.000000000 +0000 +++ six-1.5.2/six.egg-info/top_level.txt 2014-01-06 15:57:40.000000000 +0000 @@ -0,0 +1 @@ +six diff -Nru six-1.4.1/six.py six-1.5.2/six.py --- six-1.4.1/six.py 2013-09-02 13:11:12.000000000 +0000 +++ six-1.5.2/six.py 2014-01-06 15:54:24.000000000 +0000 @@ -1,6 +1,6 @@ """Utilities for writing code that runs on Python 2 and 3""" -# Copyright (c) 2010-2013 Benjamin Peterson +# Copyright (c) 2010-2014 Benjamin Peterson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ import types __author__ = "Benjamin Peterson " -__version__ = "1.4.1" +__version__ = "1.5.2" # Useful for very coarse version differentiation. @@ -84,9 +84,9 @@ def __get__(self, obj, tp): result = self._resolve() - setattr(obj, self.name, result) + setattr(obj, self.name, result) # Invokes __set__. # This is a bit ugly, but it avoids running this again. - delattr(tp, self.name) + delattr(obj.__class__, self.name) return result @@ -104,6 +104,35 @@ def _resolve(self): return _import_module(self.mod) + def __getattr__(self, attr): + # Hack around the Django autoreloader. The reloader tries to get + # __file__ or __name__ of every module in sys.modules. This doesn't work + # well if this MovedModule is for an module that is unavailable on this + # machine (like winreg on Unix systems). Thus, we pretend __file__ and + # __name__ don't exist if the module hasn't been loaded yet. See issues + # #51 and #53. + if attr in ("__file__", "__name__") and self.mod not in sys.modules: + raise AttributeError + _module = self._resolve() + value = getattr(_module, attr) + setattr(self, attr, value) + return value + + +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): @@ -131,7 +160,7 @@ -class _MovedItems(types.ModuleType): +class _MovedItems(_LazyModule): """Lazy loading of moved objects""" @@ -153,6 +182,7 @@ MovedModule("builtins", "__builtin__"), MovedModule("configparser", "ConfigParser"), MovedModule("copyreg", "copy_reg"), + MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), MovedModule("http_cookies", "Cookie", "http.cookies"), MovedModule("html_entities", "htmlentitydefs", "html.entities"), @@ -168,12 +198,14 @@ MovedModule("queue", "Queue"), MovedModule("reprlib", "repr"), MovedModule("socketserver", "SocketServer"), + MovedModule("_thread", "thread", "_thread"), MovedModule("tkinter", "Tkinter"), MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), 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", @@ -189,17 +221,21 @@ MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), + MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), MovedModule("winreg", "_winreg"), ] for attr in _moved_attributes: setattr(_MovedItems, attr.name, attr) + if isinstance(attr, MovedModule): + sys.modules[__name__ + ".moves." + attr.name] = attr del attr -moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") +_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""" @@ -223,11 +259,12 @@ setattr(Module_six_moves_urllib_parse, attr.name, attr) del attr -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") +Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes +sys.modules[__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""" @@ -240,11 +277,12 @@ setattr(Module_six_moves_urllib_error, attr.name, attr) del attr -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") +Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes + +sys.modules[__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""" @@ -281,16 +319,18 @@ 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) del attr -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") +Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes +sys.modules[__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""" @@ -304,11 +344,12 @@ setattr(Module_six_moves_urllib_response, attr.name, attr) del attr -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") +Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes + +sys.modules[__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""" @@ -319,8 +360,9 @@ setattr(Module_six_moves_urllib_robotparser, attr.name, attr) del attr -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") +Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes + +sys.modules[__name__ + ".moves.urllib_robotparser"] = sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser") class Module_six_moves_urllib(types.ModuleType): @@ -331,6 +373,9 @@ 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") @@ -464,8 +509,9 @@ else: def b(s): return s + # Workaround for standalone backslash def u(s): - return unicode(s, "unicode_escape") + return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") unichr = unichr int2byte = chr def byte2int(bs): @@ -481,8 +527,7 @@ if PY3: - import builtins - exec_ = getattr(builtins, "exec") + exec_ = getattr(moves.builtins, "exec") def reraise(tp, value, tb=None): @@ -490,10 +535,6 @@ raise value.with_traceback(tb) raise value - - print_ = getattr(builtins, "print") - del builtins - else: def exec_(_code_, _globs_=None, _locs_=None): """Execute code in a namespace.""" @@ -513,14 +554,24 @@ """) +print_ = getattr(moves.builtins, "print", None) +if print_ is None: def print_(*args, **kwargs): - """The new-style print function.""" + """The new-style print function for Python 2.4 and 2.5.""" fp = kwargs.pop("file", sys.stdout) if fp is None: return def write(data): if not isinstance(data, basestring): data = str(data) + # If the file has an encoding, encode unicode with it. + if (isinstance(fp, file) and + isinstance(data, unicode) and + fp.encoding is not None): + errors = getattr(fp, "errors", None) + if errors is None: + errors = "strict" + data = data.encode(fp.encoding, errors) fp.write(data) want_unicode = False sep = kwargs.pop("sep", None) @@ -571,7 +622,11 @@ 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 -Nru six-1.4.1/test_six.py six-1.5.2/test_six.py --- six-1.4.1/test_six.py 2013-09-01 20:46:02.000000000 +0000 +++ six-1.5.2/test_six.py 2014-01-05 16:21:00.000000000 +0000 @@ -59,11 +59,9 @@ 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(): @@ -84,21 +82,38 @@ 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): """Ensure that everything loads correctly.""" try: - getattr(six.moves, item_name) + item = getattr(six.moves, item_name) + if isinstance(item, types.ModuleType): + __import__("six.moves." + item_name) except AttributeError: if item_name == "zip_longest" and sys.version_info < (2, 6): py.test.skip("zip_longest only available on 2.6+") 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] <= (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 + assert item_name in dir(six.moves) @py.test.mark.parametrize("item_name", @@ -109,6 +124,8 @@ 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") + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.parse) getattr(six.moves.urllib.parse, item_name) @@ -116,6 +133,8 @@ [item.name for item in six._urllib_error_moved_attributes]) def test_move_items_urllib_error(item_name): """Ensure that everything loads correctly.""" + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.error) getattr(six.moves.urllib.error, item_name) @@ -123,6 +142,8 @@ [item.name for item in six._urllib_request_moved_attributes]) def test_move_items_urllib_request(item_name): """Ensure that everything loads correctly.""" + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.request) getattr(six.moves.urllib.request, item_name) @@ -130,6 +151,8 @@ [item.name for item in six._urllib_response_moved_attributes]) def test_move_items_urllib_response(item_name): """Ensure that everything loads correctly.""" + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.response) getattr(six.moves.urllib.response, item_name) @@ -137,9 +160,38 @@ [item.name for item in six._urllib_robotparser_moved_attributes]) def test_move_items_urllib_robotparser(item_name): """Ensure that everything loads correctly.""" + if sys.version_info[:2] >= (2, 6): + assert item_name in dir(six.moves.urllib.robotparser) getattr(six.moves.urllib.robotparser, item_name) +def test_import_moves_error_1(): + from six.moves.urllib.parse import urljoin + from six import moves + # In 1.4.1: AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urljoin' + assert moves.urllib.parse.urljoin + + +def test_import_moves_error_2(): + from six import moves + assert moves.urllib.parse.urljoin + # In 1.4.1: ImportError: cannot import name urljoin + from six.moves.urllib.parse import urljoin + + +def test_import_moves_error_3(): + from six.moves.urllib.parse import urljoin + # In 1.4.1: ImportError: cannot import name urljoin + from six.moves.urllib_parse import urljoin + + +def test_from_imports(): + from six.moves.queue import Queue + assert isinstance(Queue, six.class_types) + from six.moves.configparser import ConfigParser + assert isinstance(ConfigParser, six.class_types) + + def test_filter(): from six.moves import filter f = filter(lambda x: x % 2, range(10)) @@ -385,9 +437,9 @@ def test_u(): - s = six.u("hi") + s = six.u("hi \u0439 \U00000439 \\ \\\\ \n") assert isinstance(s, str) - assert s == "hi" + assert s == "hi \u0439 \U00000439 \\ \\\\ \n" else: @@ -399,9 +451,9 @@ def test_u(): - s = six.u("hi") + s = six.u("hi \u0439 \U00000439 \\ \\\\ \n") assert isinstance(s, unicode) - assert s == "hi" + assert s == "hi \xd0\xb9 \xd0\xb9 \\ \\\\ \n".decode("utf8") def test_u_escapes(): @@ -528,6 +580,24 @@ assert out.getvalue() == "None\n" +@py.test.mark.skipif("sys.version_info[:2] >= (2, 6)") +def test_print_encoding(monkeypatch): + # Fool the type checking in print_. + monkeypatch.setattr(six, "file", six.BytesIO, raising=False) + out = six.BytesIO() + out.encoding = "utf-8" + out.errors = None + six.print_(six.u("\u053c"), end="", file=out) + assert out.getvalue() == six.b("\xd4\xbc") + out = six.BytesIO() + out.encoding = "ascii" + out.errors = "strict" + py.test.raises(UnicodeEncodeError, six.print_, six.u("\u053c"), file=out) + out.errors = "backslashreplace" + six.print_(six.u("\u053c"), end="", file=out) + assert out.getvalue() == six.b("\\u053c") + + def test_print_exceptions(): py.test.raises(TypeError, six.print_, x=3) py.test.raises(TypeError, six.print_, end=3) @@ -603,7 +673,7 @@ 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) @@ -612,3 +682,14 @@ 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") +