Message52859
If I understand correctlty, _PyUnicode_AsDefaultEncodedString creates and caches a utf8 translation of the string. It returns a borrowed reference to this.
But the stored value (in ->defenc) has a refcount of 2, and will never be released when the unicode object is freed.
The effect is obvious in debug build: the total references count used to increase by 1 for each function call.
The patch is easy:
Index: Objects/unicodeobject.c
=======================================================
--- Objects/unicodeobject.c (revision 56284)
+++ Objects/unicodeobject.c (working copy)
@@ -1207,7 +1213,6 @@
PyBytes_Size(b));
Py_DECREF(b);
if (!errors) {
- Py_XINCREF(v);
((PyUnicodeObject *)unicode)->defenc = v;
}
return v;
|
|
| Date |
User |
Action |
Args |
| 2007-08-23 15:59:02 | admin | link | issue1752317 messages |
| 2007-08-23 15:59:02 | admin | create | |
|