[Patches] [ python-Patches-1494487 ] PyUnicode_Resize cannot resize shared unicode object

SourceForge.net noreply at sourceforge.net
Wed May 24 20:24:51 CEST 2006


Patches item #1494487, was opened at 2006-05-25 03:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1494487&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyUnicode_Resize cannot resize shared unicode object

Initial Comment:
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;
     }


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1494487&group_id=5470


More information about the Patches mailing list