Thanks for the repro, we'll look into it! Martin
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Giles Thomas Sent: Tuesday, February 28, 2006 5:20 AM To: Discussion of IronPython Subject: [IronPython] Possible bug with exec(code, dict) when using lambdas Hi all, It looks like there may still be outstanding problems with exec(code, dict) in beta 3; while the context in the dictionary is available to normal code, anything deferred into a function can't see it. An example might clarify: IronPython 1.0.2237 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> context = {} >>> exec("a = 1", context) >>> exec("print a", context) 1 >>> exec("b = lambda x : x + a", context) >>> exec("c = b(5)", context) Traceback (most recent call last): File , line 0, in input##105 File , line 0, in <exec>##106 File , line 0, in lambda You get the same problem if you use a regular function rather than a lambda: >>> context = {} >>> exec("a = 1", context) >>> exec("def b(x): return x + a", context) >>> exec("c = b(5)", context) Traceback (most recent call last): File , line 0, in input##80 File , line 0, in <exec>##81 File , line 0, in b NameError: name 'a' not defined >>> The same code executes as expected in CPython. Hope this is of some help to someone! Cheers, Giles -- Giles Thomas Resolver Systems [EMAIL PROTECTED] We're hiring! http://www.resolversystems.com/jobs/ _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com