Author ocean-city
Recipients
Date 2006-05-24.18:24:50
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I found following code fails.

    PyUnicodeObject *v1 = _PyUnicode_New(0);
    PyUnicodeObject *v2 = _PyUnicode_New(0);

    _PyUnicode_Resize(&v1, 1);

    Py_DECREF(v1);
    Py_DECREF(v2);

Error message is...

SystemError:
E:\python-dev\trunk\Objects\unicodeobject.c:335: bad
argument to internal function

This happens because _PyUnicode_New(0) returns
empty_unicode, and its ob_refcnt becomes 2 on second
call. I think refcnt check bellow is not needed. Is
this right fix?

Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c	(revision 46192)
+++ Objects/unicodeobject.c	(working copy)
@@ -331,7 +331,7 @@
 	return -1;
     }
     v = (PyUnicodeObject *)*unicode;
-    if (v == NULL || !PyUnicode_Check(v) ||
v->ob_refcnt != 1 || length < 0) {
+    if (v == NULL || !PyUnicode_Check(v) || length < 0) {
 	PyErr_BadInternalCall();
 	return -1;
     }
History
Date User Action Args
2007-08-23 15:52:16adminlinkissue1494487 messages
2007-08-23 15:52:16admincreate