[2.7] bpo-33422: Fix quotation marks getting deleted when looking up byte/string literals on pydoc. (GH-6701) (GH-6712)

Also update the list of string prefixes.
(cherry picked from commit b2043bbe60)
This commit is contained in:
Andrés Delfino 2018-05-07 02:44:03 -03:00 committed by Serhiy Storchaka
parent a55ac801f7
commit c40eeeb5e6
2 changed files with 10 additions and 2 deletions

View File

@ -1647,8 +1647,9 @@ class Helper:
} }
# Either add symbols to this dictionary or to the symbols dictionary # Either add symbols to this dictionary or to the symbols dictionary
# directly: Whichever is easier. They are merged later. # directly: Whichever is easier. They are merged later.
_strprefixes = tuple(p + q for p in ('b', 'r', 'u') for q in ("'", '"'))
_symbols_inverse = { _symbols_inverse = {
'STRINGS' : ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"'), 'STRINGS' : ("'", "'''", '"""', '"') + _strprefixes,
'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&', 'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
'|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'), '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'), 'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
@ -1811,7 +1812,12 @@ has the same effect as typing a particular string at the help> prompt.
if not request: break if not request: break
except (KeyboardInterrupt, EOFError): except (KeyboardInterrupt, EOFError):
break break
request = strip(replace(request, '"', '', "'", '')) request = strip(request)
# Make sure significant trailing quotation 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 lower(request) in ('q', 'quit'): break if lower(request) in ('q', 'quit'): break
self.help(request) self.help(request)

View File

@ -0,0 +1,2 @@
Fix trailing quotation marks getting deleted when looking up byte/string
literals on pydoc. Patch by Andrés Delfino.