Fix for [ 543344 ] Interpreter crashes when recoding; suggested
by Michael Stone (mbrierst).
Python 2.1.4, 2.2.2 candidate.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index cd19ab5..210be51 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -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;