@@ -1747,8 +1747,9 @@ class Helper:
1747
1747
}
1748
1748
# Either add symbols to this dictionary or to the symbols dictionary
1749
1749
# directly: Whichever is easier. They are merged later.
1750
+ _strprefixes = [p + q for p in ('b' , 'f' , 'r' , 'u' ) for q in ("'" , '"' )]
1750
1751
_symbols_inverse = {
1751
- 'STRINGS' : ("'" , "'''" , "r'" , "b'" , '"""' , '"' , 'r"' , 'b"' ),
1752
+ 'STRINGS' : ("'" , "'''" , '"' , '"""' , * _strprefixes ),
1752
1753
'OPERATORS' : ('+' , '-' , '*' , '**' , '/' , '//' , '%' , '<<' , '>>' , '&' ,
1753
1754
'|' , '^' , '~' , '<' , '>' , '<=' , '>=' , '==' , '!=' , '<>' ),
1754
1755
'COMPARISON' : ('<' , '>' , '<=' , '>=' , '==' , '!=' , '<>' ),
@@ -1910,7 +1911,13 @@ def interact(self):
1910
1911
if not request : break
1911
1912
except (KeyboardInterrupt , EOFError ):
1912
1913
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 ]
1914
1921
if request .lower () in ('q' , 'quit' ): break
1915
1922
if request == 'help' :
1916
1923
self .intro ()
0 commit comments