diff options
author | Robert Lehmann <mail@robertlehmann.de> | 2015-02-24 07:56:17 +0100 |
---|---|---|
committer | Robert Lehmann <mail@robertlehmann.de> | 2015-02-24 07:56:17 +0100 |
commit | 89c53d5a2b276f6c03c83e7d3c8d112e072f0713 (patch) | |
tree | 4d94256007201aa1ea3f84aa80c826c1eb1af28f | |
parent | 5d845a94a26596dbc9573e7b4bbd8f9cb6798697 (diff) | |
parent | baf8c0dbe1419927d175f6fdb56595e9e068d0ae (diff) | |
download | sphinx-git-89c53d5a2b276f6c03c83e7d3c8d112e072f0713.tar.gz |
Merge pull request #1727 from lehmannro/restore-pycompat
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | sphinx/util/pycompat.py | 40 |
2 files changed, 41 insertions, 1 deletions
@@ -64,6 +64,8 @@ Bugs fixed * #1718: ``:numref:`` does not work with capital letters in the label * #1630: resolve CSS conflicts, ``div.container`` css target for literal block wrapper now renamed to ``div.literal-block-wrapper``. +* ``sphinx.util.pycompat`` has been restored in its backwards-compatibility; + slated for removal in Sphinx 1.4. Release 1.3b2 (released Dec 5, 2014) diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index 62b77a655..a3ea36ba4 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -89,7 +89,7 @@ else: return ''.join(prefixed_lines()) -def execfile_(filepath, _globals): +def execfile_(filepath, _globals, open=open): from sphinx.util.osutil import fs_encoding # get config source -- 'b' is a no-op under 2.x, while 'U' is # ignored under 3.x (but 3.x compile() accepts \r\n newlines) @@ -116,3 +116,41 @@ def execfile_(filepath, _globals): else: raise exec_(code, _globals) + +# ------------------------------------------------------------------------------ +# Internal module backwards-compatibility + +import warnings + +from six import class_types +from six.moves import zip_longest +import io +from itertools import product + +class _DeprecationWrapper(object): + def __init__(self, mod, deprecated): + self._mod = mod + self._deprecated = deprecated + + def __getattr__(self, attr): + if attr in self._deprecated: + warnings.warn("sphinx.util.pycompat.%s is deprecated and will be " + "removed in Sphinx 1.4, please use the standard " + "library version instead." % attr, + DeprecationWarning, stacklevel=2) + return self._deprecated[attr] + return getattr(self._mod, attr) + +sys.modules[__name__] = _DeprecationWrapper(sys.modules[__name__], dict( + zip_longest = zip_longest, + product = product, + all = all, + any = any, + next = next, + open = open, + class_types = class_types, + base_exception = BaseException, + relpath = __import__('os').path.relpath, + StringIO = io.StringIO, + BytesIO = io.BytesIO, +)) |