diff options
author | Michael W. Hudson <mwh@python.net> | 2005-03-31 10:22:43 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2005-03-31 10:22:43 (GMT) |
commit | 21f898741e7db155cf46ec2ed61c346d4ad14261 (patch) | |
tree | 14716591a099a1346b06f4acd5678c48fff577a2 /Lib | |
parent | 59f9bea8738b5811650c53961d9a6036c3b9bcbe (diff) | |
download | cpython-21f898741e7db155cf46ec2ed61c346d4ad14261.zip cpython-21f898741e7db155cf46ec2ed61c346d4ad14261.tar.gz cpython-21f898741e7db155cf46ec2ed61c346d4ad14261.tar.bz2 |
Backport:
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.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_new.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py index f022f7e..4aab1e2 100644 --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -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 |