STINNER Victor <victor.stin...@haypocalc.com> added the comment: pyerr_warnformat.patch: create PyErr_WarnFormat() function, and use it in PyType_Ready() and PyUnicode_AsEncodedString(). The patch fixes also setup_context(): work on the unicode filename, not the encoded (bytes) filename. It does fix a bug because len is a number of characters, not a number of bytes: the number of bytes is bigger than the number of characters if the filename contains a non-ASCII character.
Advantages of PyErr_WarnFormat() over PyOS_snprintf() + PyErr_WarnEx(): - it avoids the create a temporary byte buffer: use directly an unicode buffer, - it accepts Python (unicode) formatters like %U, - it avoids the usage of a fixed size buffer allocated on the stack (which may be too big). Differences with Rietveld's version: rename PyErr_WarnUnicode() to warn_unicode() (it's now a static function) and document PyErr_WarnFormat(). ---------- nosy: +amaury.forgeotdarc, merwok, pitrou Added file: http://bugs.python.org/file18432/pyerr_warnformat.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9425> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com