Fix the SafeEncoding behaviour
Currently we have bad behaviour in SafeEncode: - binary strings are actually not handled correctly (ahem) - the encoding is not stable, due to use of string_escape For this reason, we replace the use of string_escape with part of the code of string escape (PyString_Repr in Objects/stringobject.c); we don't escape backslashes or single quotes, since that is that makes it nonstable. Furthermore, we only use the encode('ascii', ...) for unicode inputs. The patch also adds unittests for the function that test basic behaviour. Signed-off-by:Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
Loading
Please register or sign in to comment