summaryrefslogtreecommitdiff
path: root/sphinx/util/pycompat.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-03-07 20:43:25 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-04-29 15:12:39 +0900
commita86346aca6bf99a8920da366caaad7c47809ecce (patch)
tree7aa786e7817f9f3e6a338d06df2f02534d91a4c5 /sphinx/util/pycompat.py
parentaa773cbc88e692df731c78353a1043201bcb9f91 (diff)
downloadsphinx-git-a86346aca6bf99a8920da366caaad7c47809ecce.tar.gz
Remove deprecated features marked as RemovedInSphinx40Warning
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r--sphinx/util/pycompat.py54
1 files changed, 2 insertions, 52 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index 88e9ac8d5..bcd90a718 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -8,23 +8,10 @@
:license: BSD, see LICENSE for details.
"""
-import html
-import io
-import sys
-import textwrap
import warnings
from typing import Any, Callable
-from sphinx.deprecation import (
- RemovedInSphinx40Warning, RemovedInSphinx60Warning, deprecated_alias
-)
-from sphinx.locale import __
-from sphinx.util import logging
-from sphinx.util.console import terminal_safe
-from sphinx.util.typing import NoneType
-
-
-logger = logging.getLogger(__name__)
+from sphinx.deprecation import RemovedInSphinx60Warning
# ------------------------------------------------------------------------------
@@ -51,18 +38,6 @@ def convert_with_2to3(filepath: str) -> str:
return str(tree)
-class UnicodeMixin:
- """Mixin class to handle defining the proper __str__/__unicode__
- methods in Python 2 or 3.
-
- .. deprecated:: 2.0
- """
- def __str__(self) -> str:
- warnings.warn('UnicodeMixin is deprecated',
- RemovedInSphinx40Warning, stacklevel=2)
- return self.__unicode__() # type: ignore
-
-
def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None:
warnings.warn('execfile_() is deprecated',
RemovedInSphinx60Warning, stacklevel=2)
@@ -72,30 +47,5 @@ def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None:
# compile to a code object, handle syntax errors
filepath_enc = filepath.encode(fs_encoding)
- try:
- code = compile(source, filepath_enc, 'exec')
- except SyntaxError:
- # maybe the file uses 2.x syntax; try to refactor to
- # 3.x syntax using 2to3
- source = convert_with_2to3(filepath)
- code = compile(source, filepath_enc, 'exec')
- # TODO: When support for evaluating Python 2 syntax is removed,
- # deprecate convert_with_2to3().
- logger.warning(__('Support for evaluating Python 2 syntax is deprecated '
- 'and will be removed in Sphinx 4.0. '
- 'Convert %s to Python 3 syntax.'),
- filepath)
+ code = compile(source, filepath_enc, 'exec')
exec(code, _globals)
-
-
-deprecated_alias('sphinx.util.pycompat',
- {
- 'NoneType': NoneType, # type: ignore
- 'TextIOWrapper': io.TextIOWrapper,
- 'htmlescape': html.escape,
- 'indent': textwrap.indent,
- 'terminal_safe': terminal_safe,
- 'sys_encoding': sys.getdefaultencoding(),
- 'u': '',
- },
- RemovedInSphinx40Warning)