diff --git a/CHANGES b/CHANGES index cd640cb6b..e84425323 100644 --- a/CHANGES +++ b/CHANGES @@ -55,6 +55,8 @@ Deprecated ``IndexBuilder.feed()`` method is deprecated. * ``sphinx.addnodes.abbreviation`` * ``sphinx.application.Sphinx._setting_up_extension`` +* ``sphinx.cmd.quickstart.term_decode()`` +* ``sphinx.cmd.quickstart.TERM_ENCODING`` * ``sphinx.config.check_unicode()`` * ``sphinx.config.string_classes`` * ``sphinx.ext.autodoc.importer._MockImporter`` diff --git a/doc/extdev/index.rst b/doc/extdev/index.rst index 67ab1afa6..65031712a 100644 --- a/doc/extdev/index.rst +++ b/doc/extdev/index.rst @@ -152,6 +152,16 @@ The following is a list of deprecated interfaces. - 4.0 - ``docutils.nodes.abbreviation`` + * - ``sphinx.cmd.quickstart.term_decode()`` + - 2.0 + - 4.0 + - N/A + + * - ``sphinx.cmd.quickstart.TERM_ENCODING`` + - 2.0 + - 4.0 + - ``sys.stdin.encoding`` + * - ``sphinx.config.check_unicode()`` - 2.0 - 4.0 diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py index 3296c25de..22e8c1c66 100644 --- a/sphinx/cmd/quickstart.py +++ b/sphinx/cmd/quickstart.py @@ -49,7 +49,7 @@ if False: # For type annotation from typing import Any, Callable, Dict, List, Pattern, Union # NOQA -TERM_ENCODING = getattr(sys.stdin, 'encoding', None) +TERM_ENCODING = getattr(sys.stdin, 'encoding', None) # RemovedInSphinx40Warning EXTENSIONS = OrderedDict([ ('autodoc', __('automatically insert docstrings from modules')), @@ -155,6 +155,9 @@ def ok(x): def term_decode(text): # type: (Union[bytes,str]) -> str + warnings.warn('term_decode() is deprecated.', + RemovedInSphinx40Warning, stacklevel=2) + if isinstance(text, text_type): return text @@ -192,7 +195,6 @@ def do_prompt(text, default=None, validator=nonempty): x = term_input(prompt).strip() if default and not x: x = default - x = term_decode(x) try: x = validator(x) except ValidationError as err: diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index 37a426a7b..f990de857 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -8,7 +8,6 @@ :license: BSD, see LICENSE for details. """ -import sys import time from io import StringIO @@ -51,7 +50,6 @@ real_input = input def teardown_module(): qs.term_input = real_input - qs.TERM_ENCODING = getattr(sys.stdin, 'encoding', None) coloron() @@ -94,12 +92,7 @@ def test_do_prompt_with_nonascii(): 'Q1': '\u30c9\u30a4\u30c4', } qs.term_input = mock_input(answers) - try: - result = qs.do_prompt('Q1', default='\u65e5\u672c') - except UnicodeEncodeError: - raise pytest.skip.Exception( - 'non-ASCII console input not supported on this encoding: %s', - qs.TERM_ENCODING) + result = qs.do_prompt('Q1', default='\u65e5\u672c') assert result == '\u30c9\u30a4\u30c4' @@ -144,8 +137,8 @@ def test_quickstart_all_answers(tempdir): 'Root path': tempdir, 'Separate source and build': 'y', 'Name prefix for templates': '.', - 'Project name': 'STASI™'.encode(), - 'Author name': 'Wolfgang Schäuble & G\'Beckstein'.encode(), + 'Project name': 'STASI™', + 'Author name': 'Wolfgang Schäuble & G\'Beckstein', 'Project version': '2.0', 'Project release': '2.0.1', 'Project language': 'de', @@ -166,7 +159,6 @@ def test_quickstart_all_answers(tempdir): 'Do you want to use the epub builder': 'yes', } qs.term_input = mock_input(answers, needanswer=True) - qs.TERM_ENCODING = 'utf-8' d = {} qs.ask_user(d) qs.generate(d)