bpo-33422: Fix quotation marks getting deleted when looking up byte/s… · python/cpython@b2043bb

@@ -1747,8 +1747,9 @@ class Helper:

17471747

}

17481748

# Either add symbols to this dictionary or to the symbols dictionary

17491749

# directly: Whichever is easier. They are merged later.

1750+

_strprefixes = [p + q for p in ('b', 'f', 'r', 'u') for q in ("'", '"')]

17501751

_symbols_inverse = {

1751-

'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'),

1752+

'STRINGS' : ("'", "'''", '"', '"""', *_strprefixes),

17521753

'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',

17531754

'|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),

17541755

'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),

@@ -1910,7 +1911,13 @@ def interact(self):

19101911

if not request: break

19111912

except (KeyboardInterrupt, EOFError):

19121913

break

1913-

request = replace(request, '"', '', "'", '').strip()

1914+

request = request.strip()

1915+1916+

# Make sure significant trailing quoting marks of literals don't

1917+

# get deleted while cleaning input

1918+

if (len(request) > 2 and request[0] == request[-1] in ("'", '"')

1919+

and request[0] not in request[1:-1]):

1920+

request = request[1:-1]

19141921

if request.lower() in ('q', 'quit'): break

19151922

if request == 'help':

19161923

self.intro()