diff Python/getargs.c @ 12510:13a16793bb1c legacy-trunk

Marc-Andre Lemburg: Fixed a memory leak found by Fredrik Lundh. Instead of PyUnicode_AsUTF8String() we now use _PyUnicode_AsUTF8String() which returns the string object without incremented refcount (and assures that the so obtained object remains alive until the Unicode object is garbage collected).
author Guido van Rossum <guido@python.org>
date Thu, 27 Apr 2000 20:13:18 +0000
parents 65f35b73e350
children 3dbe41380266
line wrap: on
line diff
--- a/Python/getargs.c	Thu Apr 27 18:32:02 2000 +0000
+++ b/Python/getargs.c	Thu Apr 27 20:13:18 2000 +0000
@@ -444,6 +444,11 @@
 }
 
 
+/* Internal API needed by convertsimple1(): */
+extern 
+PyObject *_PyUnicode_AsUTF8String(PyObject *unicode,
+				  const char *errors);
+
 /* Convert a non-tuple argument.  Return NULL if conversion went OK,
    or a string representing the expected type if the conversion failed.
    When failing, an exception may or may not have been raised.
@@ -589,7 +594,7 @@
 			        if (PyString_Check(arg))
 				    *p = PyString_AS_STRING(arg);
 				else if (PyUnicode_Check(arg)) {
-				    arg = PyUnicode_AsUTF8String(arg);
+				    arg = _PyUnicode_AsUTF8String(arg, NULL);
 				    if (arg == NULL)
 					return "unicode conversion error";
 				    *p = PyString_AS_STRING(arg);
@@ -634,7 +639,7 @@
 				else if (PyString_Check(arg))
 				  *p = PyString_AsString(arg);
 				else if (PyUnicode_Check(arg)) {
-				  arg = PyUnicode_AsUTF8String(arg);
+				  arg = _PyUnicode_AsUTF8String(arg, NULL);
 				  if (arg == NULL)
 				      return "unicode conversion error";
 				  *p = PyString_AS_STRING(arg);