[Python-checkins] r46216 - python/trunk/Objects/stringobject.c

Fredrik Lundh fredrik at pythonware.com
Thu May 25 18:40:58 CEST 2006


Jim Jewett wrote:

>> -       newobj = PyString_FromStringAndSize(PyString_AS_STRING(self), n);
>> +       newobj = PyString_FromStringAndSize(NULL, n);
>>         if (!newobj)
>>                 return NULL;
>>
>>         s = PyString_AS_STRING(newobj);
>>
>> +       memcpy(s, PyString_AS_STRING(self), n);
> 
> Doesn't PyString_FromStringAndSize already fill newobj with a copy of
> the current string?

the problem is that if you pass in a char pointer as the first argument, 
you may get back a reference an existing Python string object...

</F>



More information about the Python-checkins mailing list