New submission from Campbell Barton: There is an inconsistency in PyUnicode_EncodeFSDefault(), on Linux its argument is checked to be unicode, and NULL is returned when its not. On windows however, this throws an assertion.
The problem with this is, in some CAPI code you may pass an argument and check for NULL as an error case, and allow the python API's exception to be exposed to the script author. The problem here is a linux developer can use PyUnicode_EncodeFSDefault() this way, but not a windows developer. A simplified use case below of a case where PyUnicode_EncodeFSDefault would fail. Attached a fix so windows and posix systems behave the same. --- const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) { if (PyBytes_Check(py_str)) { return PyBytes_AS_STRING(py_str); } else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) { return PyBytes_AS_STRING(*coerce); } --- Also: heres a list to the bug report in blenders tracker, where the bug was found. https://projects.blender.org/tracker/index.php?func=detail&aid=31856&group_id=9&atid=498 ---------- files: fix_unicode.diff keywords: patch messages: 169816 nosy: ideasman42 priority: normal severity: normal status: open title: PyUnicode_EncodeFSDefault win32 inconsistancy. Added file: http://bugs.python.org/file27114/fix_unicode.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15859> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com