[ python-Bugs-980352 ] coercion results used dangerously
SourceForge.net
noreply at sourceforge.net
Sat Jun 26 15:21:21 EDT 2004
Bugs item #980352, was opened at 2004-06-26 17:26
Message generated for change (Comment added) made by nascheme
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980352&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: coercion results used dangerously
Initial Comment:
The C core uses the result of PyNumber_CoerceEx() dangerously: it gets passed to tp_compare, and most tp_compare slots assume they get two objects of the same type. This assumption is never checked, even when a user-defined __coerce__() is called:
>>> class X(object):
... def __coerce__(self, other):
... return 4, other
...
>>> slice(1,2,3) == X()
Segmentation fault
----------------------------------------------------------------------
>Comment By: Neil Schemenauer (nascheme)
Date: 2004-06-26 19:21
Message:
Logged In: YES
user_id=35752
This bug should obviously get fixed but in long term I think
__coerce__ should go away. Do you think deprecating it for
2.4 and then removing support for it in 2.5 or 2.6 is feasible?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980352&group_id=5470
More information about the Python-bugs-list
mailing list