[issue6697] Check that _PyUnicode_AsString() result is not NULL
STINNER Victor
report at bugs.python.org
Fri Mar 5 13:13:53 CET 2010
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
MaL> If you want a fail-safe stringified version of a Unicode object,
MaL> your only choice is to create a new API that does error checking,
MaL> properly clears the error and then returns a reference to a constant
MaL> string, e.g. "<repr-error>".
I wrote a function _PyUnicode_AsStringOrDefault(unicode, default_str) which call _PyUnicode_AsStringAndSize() and return the default_str on error. It can be used in error handler (places where you don't really like to reraise new error) or if you don't care about (unicode) errors.
----------
Added file: http://bugs.python.org/file16458/pyunicode_asstringordefault.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6697>
_______________________________________
More information about the Python-bugs-list
mailing list