8000 [2.7] bpo-33422: Fix quotation marks getting deleted when looking up … · python/cpython@c40eeeb · GitHub
[go: up one dir, main page]

Skip to content

Commit c40eeeb

Browse files
andresdelfinoserhiy-storchaka
authored andcommitted
[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 b2043bb)
1 parent a55ac80 commit c40eeeb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Lib/pydoc.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,9 @@ class Helper:
16471647
}
16481648
# Either add symbols to this dictionary or to the symbols dictionary
16491649
# directly: Whichever is easier. They are merged later.
1650+
_strprefixes = tuple(p + q for p in ('b', 'r', 'u') for q in ("'", '"'))
16501651
_symbols_inverse = {
1651-
'STRINGS' : ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"'),
1652+
'STRINGS' : ("'", "'''", '"""', '"') + _strprefixes,
16521653
'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
16531654
'|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
16541655
'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
@@ -1811,7 +1812,12 @@ def interact(self):
18111812
if not request: break
18121813
except (KeyboardInterrupt, EOFError):
18131814
break
1814-
request = strip(replace(request, '"', '', "'", ''))
1815+
request = strip(request)
1816+
# Make sure significant trailing quotation marks of literals don't
1817+
# get deleted while cleaning input
1818+
if (len(request) > 2 and request[0] == request[-1] in ("'", '"')
1819+
and request[0] not in request[1:-1]):
1820+
request = request[1:-1]
18151821
if lower(request) in ('q', 'quit'): break
18161822
self.help(request)
18171823

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix trailing quotation marks getting deleted when looking up byte/string
2+
literals on pydoc. Patch by Andrés Delfino.

0 commit comments

Comments
 (0)
0