summaryrefslogtreecommitdiff
path: root/sphinx/util/pycompat.py
diff options
context:
space:
mode:
authorRobert Lehmann <mail@robertlehmann.de>2015-02-24 07:56:17 +0100
committerRobert Lehmann <mail@robertlehmann.de>2015-02-24 07:56:17 +0100
commit89c53d5a2b276f6c03c83e7d3c8d112e072f0713 (patch)
tree4d94256007201aa1ea3f84aa80c826c1eb1af28f /sphinx/util/pycompat.py
parent5d845a94a26596dbc9573e7b4bbd8f9cb6798697 (diff)
parentbaf8c0dbe1419927d175f6fdb56595e9e068d0ae (diff)
downloadsphinx-git-89c53d5a2b276f6c03c83e7d3c8d112e072f0713.tar.gz
Merge pull request #1727 from lehmannro/restore-pycompat
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r--sphinx/util/pycompat.py40
1 files changed, 39 insertions, 1 deletions
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,
+))