Issue543344
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-04-13 08:12 by loewis, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (5) | |||
---|---|---|---|
msg10307 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-04-13 08:12 | |
Python crashes when executing import codecs f = open("syllables", "w+") f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8") f2.write(u"a") f2.close() |
|||
msg10308 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-04-13 08:36 | |
Logged In: YES user_id=31435 Here's a clue from a debug-mode build: >>> import codecs [9477 refs] >>> f = open("syllables", "w+") [9483 refs] >>> f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8") [9830 refs] >>> f2.write(u"a") C:\Code\python\Objects\tupleobject.c:147 negative ref count -1 |
|||
msg10309 - (view) | Author: Michael Stone (mbrierst) | Date: 2003-02-04 19:03 | |
Logged In: YES user_id=670441 This was a problem in Modules/_codecsmodule.c Throughout most of the module, objects retrieved through PyArg_ParseTuple are converted to new types, but in this one line the object is used directly. In that case we must INCREF it as PyArg_ParseTuple will not. Patch below: Index: dist/src/Modules/_codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.16 diff -c -r2.16 _codecsmodule.c *** dist/src/Modules/_codecsmodule.c 31 Oct 2002 13:36:29 -0000 2.16 --- dist/src/Modules/_codecsmodule.c 4 Feb 2003 18:53:50 -0000 *************** *** 167,174 **** &obj, &errors)) return NULL; ! if (PyUnicode_Check(obj)) return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); else { if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) return NULL; --- 167,176 ---- &obj, &errors)) return NULL; ! if (PyUnicode_Check(obj)) { ! Py_INCREF(obj); return codec_tuple(obj, PyUnicode_GET_SIZE(obj)); + } else { if (PyObject_AsReadBuffer(obj, (const void **)&data, &size)) return NULL; |
|||
msg10310 - (view) | Author: Marc-Andre Lemburg (lemburg) * | Date: 2003-02-04 19:23 | |
Logged In: YES user_id=38388 Good catch. I'll check in the patch. Thanks. |
|||
msg10311 - (view) | Author: Marc-Andre Lemburg (lemburg) * | Date: 2003-02-04 19:41 | |
Logged In: YES user_id=38388 Checking in Lib/test/test_codecs.py; /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v <-- test_codecs.py new revision: 1.5; previous revision: 1.4 done Checking in Modules/_codecsmodule.c; /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v <-- _codecsmodule.c new revision: 2.17; previous revision: 2.16 done |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:12 | admin | set | github: 36426 |
2002-04-13 08:12:32 | loewis | create |