bpo-33422: Fix quotation marks getting deleted when looking up byte/s… · python/cpython@0ba812b (original) (raw)
`@@ -1716,8 +1716,9 @@ class Helper:
`
1716
1716
` }
`
1717
1717
`# Either add symbols to this dictionary or to the symbols dictionary
`
1718
1718
`# directly: Whichever is easier. They are merged later.
`
``
1719
`+
_strprefixes = [p + q for p in ('b', 'f', 'r', 'u') for q in ("'", '"')]
`
1719
1720
`_symbols_inverse = {
`
1720
``
`-
'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'),
`
``
1721
`+
'STRINGS' : ("'", "'''", '"', '"""', *_strprefixes),
`
1721
1722
`'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
`
1722
1723
`'|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
`
1723
1724
`'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
`
`@@ -1874,7 +1875,13 @@ def interact(self):
`
1874
1875
`if not request: break
`
1875
1876
`except (KeyboardInterrupt, EOFError):
`
1876
1877
`break
`
1877
``
`-
request = replace(request, '"', '', "'", '').strip()
`
``
1878
`+
request = request.strip()
`
``
1879
+
``
1880
`+
Make sure significant trailing quoting marks of literals don't
`
``
1881
`+
get deleted while cleaning input
`
``
1882
`+
if (len(request) > 2 and request[0] == request[-1] in ("'", '"')
`
``
1883
`+
and request[0] not in request[1:-1]):
`
``
1884
`+
request = request[1:-1]
`
1878
1885
`if request.lower() in ('q', 'quit'): break
`
1879
1886
`if request == 'help':
`
1880
1887
`self.intro()
`