From: Jeremy Hylton Date: Mon, 30 Jul 2001 21:55:29 +0000 (+0000) Subject: Fix for SF bug [ #443866 ] Evaluating func_code causing core dump X-Git-Tag: v2.2a3~922 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5121e7de11eaf8ef872aef4b0c58612d6a814161;p=thirdparty%2FPython%2Fcpython.git Fix for SF bug [ #443866 ] Evaluating func_code causing core dump Add test that calls eval with a code object that has free variables. --- diff --git a/Lib/test/output/test_scope b/Lib/test/output/test_scope index 1a44bb2d14ba..55a8787aadc6 100644 --- a/Lib/test/output/test_scope +++ b/Lib/test/output/test_scope @@ -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 diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index cb06036677db..58dd637505b1 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -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"