Issue1752317
Created on 2007-07-11 23:57 by amaury.forgeotdarc, last changed 2008-01-06 22:29 by admin.
| Messages (3) | |||
|---|---|---|---|
| msg52859 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) | Date: 2007-07-11 23:57 | |
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; |
|||
| msg52860 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) | Date: 2007-07-12 00:00 | |
Of course, sourceforge ate the spaces again... sorry. Here is the patch again: Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 56284) +++ Objects/unicodeobject.c (working copy) @@ -1207,7 +1207,6 @@ PyBytes_Size(b)); Py_DECREF(b); if (!errors) { - Py_XINCREF(v); ((PyUnicodeObject *)unicode)->defenc = v; } return v; |
|||
| msg52861 - (view) | Author: Guido van Rossum (gvanrossum) | Date: 2007-07-12 07:53 | |
Good analysis! Fixed. Committed revision 56288. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-01-06 22:29:45 | admin | set | keywords:
- py3k versions: + Python 3.0 |
| 2007-07-11 23:57:32 | amaury.forgeotdarc | create | |