diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-12-17 06:22:37 -0800 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-12-17 06:44:17 -0800 |
commit | 43ff640b5868632e5cc227575fb5afdf2e0e015a (patch) | |
tree | 7cd57230f4a25d22d06106bbcaebde17fe531849 /sphinx/cmd/quickstart.py | |
parent | 0a199c08b834e8416ddec7d2b4b4f6e8950f8196 (diff) | |
download | sphinx-git-43ff640b5868632e5cc227575fb5afdf2e0e015a.tar.gz |
Deprecate quickstart.term_decode() and remove internal uses
Per the Python 3 docs, input() always returns a string:
https://docs.python.org/3/library/functions.html#input
> The function then reads a line from input, converts it to a
> string (stripping a trailing newline), and returns that.
The stubs from typeshed say the same:
https://github.com/python/typeshed/blob/5c69373890dfaf4f07f0638766fb0a4903352892/stdlib/3/builtins.pyi#L835
Here is the implementation from CPython with also shows a call to
PyUnicode_Decode on the result:
https://github.com/python/cpython/blob/3.7/Python/bltinmodule.c#L1960-L2143
As the value is always a string, there is nothing to decode. Therefore
the call to term_decode() unnecessary and can safely be removed.
With this in mind, must adjust quickstart tests to be more
representative.
Diffstat (limited to 'sphinx/cmd/quickstart.py')
-rw-r--r-- | sphinx/cmd/quickstart.py | 6 |
1 files changed, 4 insertions, 2 deletions
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: |