[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
STINNER Victor victor.stin...@haypocalc.com added the comment: Fixed in Python 3.3: r88708 removes errors argument of _PyUnicode_AsDefaultEncodedString(), r88709 caches the result of str.encode(). replace all uses of _PyUnicode_AsDefaultEncodedString() with PyUnicode_AsUTF8String() It makes the code more complex because PyUnicode_AsUTF8String() increments the reference counter. I prefer to keep _PyUnicode_AsDefaultEncodedString(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
Changes by STINNER Victor victor.stin...@haypocalc.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
STINNER Victor victor.stin...@haypocalc.com added the comment: Since Python3 fixes the UTF-8 default encoding, it's better to enhance PyUnicode_AsUTF8String() to cache the UTF-8 string in the Unicode object Right, that sounds like a great idea. Attached patch implements that: patch PyUnicode_AsUTF8String() and PyUnicode_AsEncodedString(). Does it look ok? replace all uses of _PyUnicode_AsDefaultEncodedString() with PyUnicode_AsUTF8String() I'm waiting for your approval of the first patch before working on the second part. -- Added file: http://bugs.python.org/file17595/utf8_defenc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: Since Python3 fixes the UTF-8 default encoding, it's better to enhance PyUnicode_AsUTF8String() to cache the UTF-8 string in the Unicode object Right, that sounds like a great idea. Attached patch implements that: patch PyUnicode_AsUTF8String() and PyUnicode_AsEncodedString(). Does it look ok? Looks good. replace all uses of _PyUnicode_AsDefaultEncodedString() with PyUnicode_AsUTF8String() I'm waiting for your approval of the first patch before working on the second part. When replacing uses of _PyUnicode_AsDefaultEncodedString() with PyUnicode_AsUTF8String() you have to take great care to decref the object returned by the latter. Otherwise, we get huge memory leaks. -- title: Remove unused errors argument from _PyUnicode_AsDefaultEncodedString() - Remove unused errors argument from _PyUnicode_AsDefaultEncodedString() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: New submission from STINNER Victor victor.stin...@haypocalc.com: _PyUnicode_AsDefaultEncodedString() has two arguments: unicode (input string) and errors. If errors is not NULL, it calls Py_FatalError()! The argument is useful: all functions call it with errors=NULL. Attached patch removes the argument. While it's an internal API, it's still public and we cannot just remove the extra argument - we're in stable branch mode. Since Python3 fixes the UTF-8 default encoding, it's better to enhance PyUnicode_AsUTF8String() to cache the UTF-8 string in the Unicode object or simply return it directly and then replace all uses of _PyUnicode_AsDefaultEncodedString() with PyUnicode_AsUTF8String(). We should phase out use of _PyUnicode_AsDefaultEncodedString() as well as the whole default encoding terminology altogether. Please also add a documentation patch and a NEWS entry. -- nosy: +lemburg title: Remove unused errors argument from _PyUnicode_AsDefaultEncodedString() - Remove unused errors argument from _PyUnicode_AsDefaultEncodedString() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8923] Remove unused errors argument from _PyUnicode_AsDefaultEncodedString()
New submission from STINNER Victor victor.stin...@haypocalc.com: _PyUnicode_AsDefaultEncodedString() has two arguments: unicode (input string) and errors. If errors is not NULL, it calls Py_FatalError()! The argument is useful: all functions call it with errors=NULL. Attached patch removes the argument. -- components: Unicode files: unicode_errors.patch keywords: patch messages: 107204 nosy: haypo priority: normal severity: normal status: open title: Remove unused errors argument from _PyUnicode_AsDefaultEncodedString() versions: Python 3.2 Added file: http://bugs.python.org/file17575/unicode_errors.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8923 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com