]> granicus.if.org Git - python/commitdiff
Bug #1511381: codec_getstreamcodec() in codec.c is corrected to
authorHye-Shik Chang <hyeshik@gmail.com>
Fri, 23 Jun 2006 21:16:18 +0000 (21:16 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Fri, 23 Jun 2006 21:16:18 +0000 (21:16 +0000)
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)

Misc/NEWS
Python/codecs.c

index ae1963f6793456d70f71f4a61c8b846039b5f9d7..76acf30880dbe598b41859ff80b5759ed7eb823e 100644 (file)
--- 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
 -------
index 046abe35079af3208762ad4bea0e6dcd6a315aaa..4b0f4cb0d04f91771d4ee617f2f0a4e380321fe2 100644 (file)
@@ -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;
 }