mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix for rather inaccurately titled bug
[ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate.
This commit is contained in:
parent
5c473559e5
commit
e2749cb264
2 changed files with 16 additions and 0 deletions
|
@ -47,6 +47,16 @@ im()
|
|||
verify(c.get_yolks() == 1 and c.get_more_yolks() == 4,
|
||||
'Broken call of hand-crafted instance method')
|
||||
|
||||
im = new.instancemethod(break_yolks, c)
|
||||
im()
|
||||
verify(c.get_yolks() == -1)
|
||||
try:
|
||||
new.instancemethod(break_yolks, None)
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
raise TestFailed, "dangerous instance method creation allowed"
|
||||
|
||||
# It's unclear what the semantics should be for a code object compiled at
|
||||
# module scope, but bound and run in a function. In CPython, `c' is global
|
||||
# (by accident?) while in Jython, `c' is local. The intent of the test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue