refactor: deprecate some pycompat functions

This commit is contained in:
Takeshi KOMIYA 2019-01-07 22:27:05 +09:00
parent 353c3e9fd6
commit 39c0380c4d
4 changed files with 33 additions and 9 deletions

View File

@ -99,7 +99,10 @@ Deprecated
* ``sphinx.util.osutil.EPIPE`` * ``sphinx.util.osutil.EPIPE``
* ``sphinx.util.osutil.walk()`` * ``sphinx.util.osutil.walk()``
* ``sphinx.util.PeekableIterator`` * ``sphinx.util.PeekableIterator``
* ``sphinx.util.pycompat.TextIOWrapper``
* ``sphinx.util.pycompat.UnicodeMixin`` * ``sphinx.util.pycompat.UnicodeMixin``
* ``sphinx.util.pycompat.htmlescape``
* ``sphinx.util.pycompat.indent``
* ``sphinx.util.pycompat.u`` * ``sphinx.util.pycompat.u``
* ``sphinx.writers.latex.ExtBabel`` * ``sphinx.writers.latex.ExtBabel``
* ``sphinx.writers.latex.LaTeXTranslator._make_visit_admonition()`` * ``sphinx.writers.latex.LaTeXTranslator._make_visit_admonition()``

View File

@ -378,11 +378,26 @@ The following is a list of deprecated interfaces.
- 4.0 - 4.0
- ``os.walk()`` - ``os.walk()``
* - ``sphinx.util.pycompat.TextIOWrapper``
- 2.0
- 4.0
- ``io.TextIOWrapper``
* - ``sphinx.util.pycompat.UnicodeMixin`` * - ``sphinx.util.pycompat.UnicodeMixin``
- 2.0 - 2.0
- 4.0 - 4.0
- N/A - N/A
* - ``sphinx.util.pycompat.htmlescape()``
- 2.0
- 4.0
- ``html.escape()``
* - ``sphinx.util.pycompat.indent()``
- 2.0
- 4.0
- ``textwrap.indent()``
* - ``sphinx.util.pycompat.u`` * - ``sphinx.util.pycompat.u``
- 2.0 - 2.0
- 4.0 - 4.0

View File

@ -9,6 +9,7 @@
""" """
from os import path from os import path
from textwrap import indent
from typing import Any, TypeVar from typing import Any, TypeVar
from docutils import nodes from docutils import nodes
@ -25,7 +26,6 @@ from sphinx.util.nodes import (
LITERAL_TYPE_NODES, IMAGE_TYPE_NODES, NodeMatcher, LITERAL_TYPE_NODES, IMAGE_TYPE_NODES, NodeMatcher,
extract_messages, is_pending_meta, traverse_translatable_index, extract_messages, is_pending_meta, traverse_translatable_index,
) )
from sphinx.util.pycompat import indent
if False: if False:
# For type annotation # For type annotation

View File

@ -8,13 +8,13 @@
:license: BSD, see LICENSE for details. :license: BSD, see LICENSE for details.
""" """
import html
import io
import sys import sys
import textwrap
import warnings import warnings
from html import escape as htmlescape # NOQA
from io import TextIOWrapper # NOQA
from textwrap import indent # NOQA
from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.locale import __ from sphinx.locale import __
from sphinx.util import logging from sphinx.util import logging
@ -31,10 +31,6 @@ NoneType = type(None)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Python 2/3 compatibility # Python 2/3 compatibility
# prefix for Unicode strings
u = '' # RemovedInSphinx40Warning
# sys_encoding: some kind of default system encoding; should be used with # sys_encoding: some kind of default system encoding; should be used with
# a lenient error handler # a lenient error handler
sys_encoding = sys.getdefaultencoding() sys_encoding = sys.getdefaultencoding()
@ -99,3 +95,13 @@ def execfile_(filepath, _globals, open=open):
'Convert %s to Python 3 syntax.'), 'Convert %s to Python 3 syntax.'),
filepath) filepath)
exec(code, _globals) exec(code, _globals)
deprecated_alias('sphinx.util.pycompat',
{
'TextIOWrapper': io.TextIOWrapper,
'htmlescape': html.escape,
'indent': textwrap.indent,
'u': '',
},
RemovedInSphinx40Warning)