STINNER Victor <victor.stin...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue6697> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com