]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix for SF bug [ #443866 ] Evaluating func_code causing core dump
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 30 Jul 2001 21:55:29 +0000 (21:55 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 30 Jul 2001 21:55:29 +0000 (21:55 +0000)
Add test that calls eval with a code object that has free variables.

Lib/test/output/test_scope
Lib/test/test_scope.py

index 1a44bb2d14ba4093b9906a64b5c6186407d65741..55a8787aadc624e2fb6481c0eb7db2b1ce81d1ab 100644 (file)
@@ -19,3 +19,4 @@ test_scope
 18. verify that locals() works
 19. var is bound and free in class
 20. interaction with trace function
+20. eval with free variables
index cb06036677db320eea57ef1d22ec376599ae4c0f..58dd637505b1cbe09143375a6f1bfac7bb694200 100644 (file)
@@ -465,3 +465,16 @@ class TestClass:
 sys.settrace(tracer)
 adaptgetter("foo", TestClass, (1, ""))
 sys.settrace(None)
+
+print "20. eval with free variables"
+
+def f(x):
+    return lambda: x + 1
+
+g = f(3)
+try:
+    eval(g.func_code)
+except TypeError:
+    pass
+else:
+    print "eval() should have failed, because code contained free vars"