[Python-bugs-list] [ python-Bugs-416187 ] API problem causes unicode memory leak

noreply@sourceforge.net noreply@sourceforge.net
Sat, 14 Apr 2001 20:05:07 -0700


Bugs item #416187, was updated on 2001-04-14 14:11
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416187&group_id=5470

Category: Python Library
Group: None
Status: Open
>Priority: 9
Submitted By: douglas orr (dougbo)
Assigned to: Nobody/Anonymous (nobody)
Summary: API problem causes unicode memory leak

Initial Comment:
The API PyString_ASString returns a pointer to a char 
* representation of its argument.  

PyString_ASStringAndSize tries to convert it to the 
default encoding.  In the process it makes a new 
string object holding the newly encoded buffer, it 
returns a pointer to the buffer (bad idea) and leaks 
the new object and the buffer -- which is the only 
choice since there is no control on how long the 
pointer to the buffer needs to be valid.

It should probably throw an error if you give it a 
unicode string and force you to convert it explicitly, 
before calling the API.

I encountered this problem trying to use XML data.


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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-04-14 20:05

Message:
Logged In: YES 
user_id=6380

Shit!  You're right.  What now?  if I change it to throw an
error, how do I know it won't break some code that depends
on this???

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

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416187&group_id=5470