Patches item #1752317, was opened at 2007-07-12 01:57 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1752317&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core (C code) Group: Python 3000 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Amaury Forgeot d'Arc (amauryf) Assigned to: Nobody/Anonymous (nobody) Summary: reference leak in _PyUnicode_AsDefaultEncodedString Initial Comment: 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; ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1752317&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches