diff Modules/_codecsmodule.c @ 27680:b19aaaeb6d64 legacy-trunk

Fix for [ 543344 ] Interpreter crashes when recoding; suggested by Michael Stone (mbrierst). Python 2.1.4, 2.2.2 candidate.
author Marc-André Lemburg <mal@egenix.com>
date Tue, 04 Feb 2003 19:35:03 +0000
parents 040af9c736bb
children 8ea2cb1ec598
line wrap: on
line diff
--- a/Modules/_codecsmodule.c	Tue Feb 04 19:13:07 2003 +0000
+++ b/Modules/_codecsmodule.c	Tue Feb 04 19:35:03 2003 +0000
@@ -167,8 +167,10 @@
 			  &obj, &errors))
 	return NULL;
 
-    if (PyUnicode_Check(obj))
+    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;