Eric V. Smith added the comment:
Here is an extremely rough patch that shows the basic concept. I named the
private function _PyUnicode_DecodeUnicodeEscape.
The problems with this patch are:
1. it always raises an error, not a warning
2. the private function isn't declared in a .h file
3. the name of the private function needs some thought
4. only the first invalid escape in a string is reported
5. I don't report the correct location in the string with the invalid escape
6. there may well be a memory leak
7. PEP 7 problems
#1 is because I was too lazy to refactor ast_error() to format the string I
need without raising an error.
#5 could be solved with a callback and something to record multiple bad escapes
per string, if we want to go that far. We'd have to decide how to show this.
Multiple warnings, or one warning with multiple bad chars?
The rest of it is just quality of implementation stuff that we can work out if
the approach is sound.
Added file: http://bugs.python.org/file44694/28128.diff
Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list