This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: forcing function to act like an unbound method dumps core
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: akuchling, barry, df-dubois, nnorwitz
Priority: high Keywords:

Created on 2003-05-13 07:57 by df-dubois, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Messages (5)
msg15985 - (view) Author: Paul Du Bois (df-dubois) Date: 2003-05-13 07:57
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
msg15986 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-05-13 18:27
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.

msg15987 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-05-22 21:13
Logged In: YES 
user_id=33168

Bumping priority.  Barry, do you want to handle this for 2.2.3?
msg15988 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2003-05-23 04:38
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.
msg15989 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2003-05-29 15:14
Logged In: YES 
user_id=12800

Fixed by backporting typeobject.c 2.206 patch.  I also added
a simple test.
History
Date User Action Args
2022-04-10 16:08:44adminsetgithub: 38495
2003-05-13 07:57:16df-duboiscreate