[Python-checkins] python/dist/src/Lib/test test_new.py, 1.19, 1.19.2.1

mwh at users.sourceforge.net mwh at users.sourceforge.net
Thu Mar 31 12:22:46 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5596/Lib/test

Modified Files:
      Tag: release24-maint
	test_new.py 
Log Message:
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.



Index: test_new.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -d -r1.19 -r1.19.2.1
--- test_new.py	13 Aug 2004 03:57:22 -0000	1.19
+++ test_new.py	31 Mar 2005 10:22:43 -0000	1.19.2.1
@@ -47,6 +47,16 @@
 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



More information about the Python-checkins mailing list