From: Hye-Shik Chang Date: Fri, 23 Jun 2006 21:16:18 +0000 (+0000) Subject: Bug #1511381: codec_getstreamcodec() in codec.c is corrected to X-Git-Tag: v2.5b2~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6a1cb97000a566338fd484cbb0e7aa2e95185d8;p=python Bug #1511381: codec_getstreamcodec() in codec.c is corrected to omit a default "error" argument for NULL pointer. This allows the parser to take a codec from cjkcodecs again. (Reported by Taewook Kang and reviewed by Walter Doerwald) --- diff --git a/Misc/NEWS b/Misc/NEWS index ae1963f679..76acf30880 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2? Core and builtins ----------------- +- Bug #1511381: codec_getstreamcodec() in codec.c is corrected to + omit a default "error" argument for NULL pointer. This allows + the parser to take a codec from cjkcodecs again. Library ------- diff --git a/Python/codecs.c b/Python/codecs.c index 046abe3507..4b0f4cb0d0 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -249,14 +249,17 @@ PyObject *codec_getstreamcodec(const char *encoding, const char *errors, const int index) { - PyObject *codecs, *streamcodec; + PyObject *codecs, *streamcodec, *codeccls; codecs = _PyCodec_Lookup(encoding); if (codecs == NULL) return NULL; - streamcodec = PyEval_CallFunction( - PyTuple_GET_ITEM(codecs, index), "Os", stream, errors); + codeccls = PyTuple_GET_ITEM(codecs, index); + if (errors != NULL) + streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors); + else + streamcodec = PyObject_CallFunction(codeccls, "O", stream); Py_DECREF(codecs); return streamcodec; }