[Patches] [ python-Patches-1680015 ] __slots__ tuple modified inplace if it contains unicode name

SourceForge.net noreply at sourceforge.net
Wed Mar 14 10:36:16 CET 2007


Patches item #1680015, was opened at 2007-03-13 17:44
Message generated for change (Settings changed) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1680015&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: Accepted
Priority: 5
Private: No
Submitted By: Žiga Seilnacht (zseil)
>Assigned to: Žiga Seilnacht (zseil)
Summary: __slots__ tuple modified inplace if it contains unicode name

Initial Comment:
Function _unicode_to_string() in typeobject.c
tries to copy the original tuple by asking for
a complete slice of the original tuple. This
case is special cased in tupleslice() to only
incref the original tuple. As a consequence,
the user's tuple could be modified (see
the test). 
There are also some reference leaks if an
unicode name can't be encoded with the default
codec. 
The patch fixes this and adds tests for both
cases. I also moved a comment about possible
leaks to the appropriate place.


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

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-13 18:57

Message:
Logged In: YES 
user_id=849994
Originator: NO

Perhaps moving the "leak" comment into the if block isn't such a good
idea.

Ah, and while you're at it, you could improve the variable names ("o" and
"o1" is not very useful :)

Otherwise the patch looks fine, I'd say you can apply it then.

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

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


More information about the Patches mailing list