diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-05-05 16:42:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-05 16:42:56 (GMT) |
commit | 351782b9927c610ff531100dbdcbbd19d91940a3 (patch) | |
tree | f4e61000172685cb70f0d77e00f83e444cca7365 /Lib/pydoc.py | |
parent | 6a56790e0b50846f1f968e48c3a321c148b5e6cd (diff) | |
download | cpython-351782b9927c610ff531100dbdcbbd19d91940a3.zip cpython-351782b9927c610ff531100dbdcbbd19d91940a3.tar.gz cpython-351782b9927c610ff531100dbdcbbd19d91940a3.tar.bz2 |
bpo-33422: Fix quotation marks getting deleted when looking up byte/string literals on pydoc. (GH-6701)
Also update the list of string prefixes.
(cherry picked from commit b2043bbe6034b53f5ad337887f4741b74b70b00d)
Co-authored-by: Andrés Delfino <adelfino@gmail.com>
Diffstat (limited to 'Lib/pydoc.py')
-rw-r--r-- | Lib/pydoc.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index e7a1655..199745c 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1747,8 +1747,9 @@ class Helper: } # Either add symbols to this dictionary or to the symbols dictionary # directly: Whichever is easier. They are merged later. + _strprefixes = [p + q for p in ('b', 'f', 'r', 'u') for q in ("'", '"')] _symbols_inverse = { - 'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'), + 'STRINGS' : ("'", "'''", '"', '"""', *_strprefixes), 'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&', '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'), 'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'), @@ -1910,7 +1911,13 @@ has the same effect as typing a particular string at the help> prompt. if not request: break except (KeyboardInterrupt, EOFError): break - request = replace(request, '"', '', "'", '').strip() + request = request.strip() + + # Make sure significant trailing quoting marks of literals don't + # get deleted while cleaning input + if (len(request) > 2 and request[0] == request[-1] in ("'", '"') + and request[0] not in request[1:-1]): + request = request[1:-1] if request.lower() in ('q', 'quit'): break if request == 'help': self.intro() |