[Python-bugs-list] [ python-Bugs-736892 ] forcing function to act like an unbound method dumps core

SourceForge.net noreply@sourceforge.net
Thu, 29 May 2003 08:14:56 -0700


Bugs item #736892, was opened at 2003-05-13 03:57
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=736892&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2.2
>Status: Closed
>Resolution: Fixed
Priority: 7
Submitted By: Paul Du Bois (df-dubois)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: forcing function to act like an unbound method dumps core

Initial Comment:
Using ActivePython, v2.2.2

I was reading PEP252 and trying stupid things, like this:

k [ 0:51] python
ActivePython 2.2.2 Build 224 (ActiveState Corp.) based 
on
Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> def func(): pass
...
>>> f = func.__get__()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: function takes at least 1 argument (0 given)
>>> f = func.__get__(None)
>>> f()    # This gives a reasonable result
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unbound method func() must be called with ? 
instance as first argument (got nothing instead)
>>> f(1)    # This crashes accessing a null pointer

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

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-05-29 11:14

Message:
Logged In: YES 
user_id=12800

Fixed by backporting typeobject.c 2.206 patch.  I also added
a simple test.

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

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-05-23 00:38

Message:
Logged In: YES 
user_id=12800

Yes, let's try to get this fix into 2.2.3 final.  I'll look at it if nobody beats me 
to it.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-05-22 17:13

Message:
Logged In: YES 
user_id=33168

Bumping priority.  Barry, do you want to handle this for 2.2.3?

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

Comment By: A.M. Kuchling (akuchling)
Date: 2003-05-13 14:27

Message:
Logged In: YES 
user_id=11375

It seems to be fixed in 2.3CVS:

>>> f = func.__get__(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __get__(None, None) is invalid

The fix needs to be backported to the 2.2 branch.



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

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