Eric V. Smith added the comment:

Couldn't we create a private version of PyUnicode_DecodeUnicodeEscape, to be 
called by ast.c, which passes back invalid escape info? Then have the actual 
warning raised by ast.c, which knows enough about the context to generate a 
better error/warning. I think we'd only be able to report on he first error in 
a string, though, but I haven't thought it all the way through.

I believe we'd only need to modify decode_unicode_with_escapes() in ast.c, 
which is called for both regular strings and f-string. And of course 
PyUnicode_DecodeUnicodeEscape would have to call the new private version and do 
the right thing.


Python tracker <>
Python-bugs-list mailing list

Reply via email to