<html><head><style type="text/css" media="screen">Body{font-family: Verdana;font-size:.75em;}h4{font-size:.9em;}a{color: #3a62a6;}.digest .toc {margin-bottom: 15px; padding-bottom:8px; border-bottom: 1px solid #ccc;}.digest .tocItem {margin-bottom: 15px;}.tocItem a{color:#000;text-decoration: none;}.tocItem a:hover{color: #3a62a6;text-decoration: underline;}.topic{padding-bottom: 8px;margin-bottom: 20px; border-bottom: 1px solid #ccc;}.topicHeader{margin-bottom:10px;}.topicTitle{font-weight: bold;}.replies p{margin:0;padding:0;}.replies hr{width: 15%;text-align: left;margin: 0 auto 5px 0;border: none 0;border-top: 1px solid #ccc;height: 1px;}.reply{margin-bottom: 6px;padding-bottom: 4px;}.anchorMarker{color: #3a62a6;}.footer{color: gray;}</style></head><body><div class="digest"><p>Hi ironpython,</p><p>Here's your Daily Digest of new issues for project "<a href="http://ironpython.codeplex.com/">IronPython</a>".</p><p>In today's digest:</p><h4>ISSUES</h4><div class="toc"><div class="tocItem"><a href="#toc_issue_1">1. <span class="tocTitle">[New issue] Scope is not remembered after an import</span> <span class="anchorMarker">↓</span></a></div><div class="tocItem"><a href="#toc_issue_2">2. <span class="tocTitle">[New comment] Scope is not remembered after an import</span> <span class="anchorMarker">↓</span></a></div></div><h4>ISSUES</h4><div class="topic"><a name="toc_issue_1"></a><div class="topicHeader"><span class="topicTitle">1. [New issue] Scope is not remembered after an import</span> <a href="http://ironpython.codeplex.com/workitem/30955">view online</a></div><p>User WimVanLoocke has proposed the issue:</p><p>"When using ironpython to run py scripts, one creates in c# as scope for the engine, and sets a variable.<br /><br />When running the .py file is executed and the scope is know.<br />When running a .py file that imports an other .py file( can contains ref to variable in the scope ) the variable is no longer know.<br /><br />When looking into the code <br /><br />{ snipped }<br />internal PythonModule/*!*/ CompileModule(string fileName, string moduleName, SourceUnit sourceCode, ModuleOptions options, out ScriptCode scriptCode) {<br /><br />ContractUtils.RequiresNotNull(fileName, "fileName");<br /><br />ContractUtils.RequiresNotNull(moduleName, "moduleName");<br /><br />ContractUtils.RequiresNotNull(sourceCode, "sourceCode");<br /><br />scriptCode = GetScriptCode(sourceCode, moduleName, options);<br /><br />Scope scope = scriptCode.CreateScope();<br /><br />return InitializeModule(fileName, ((PythonScopeExtension)scope.GetExtension(ContextId)).ModuleContext, scriptCode, options);<br /><br />}<br /><br />{ end snipped }<br /><br />you can see that a new scope is created, and not the initial scope is used.<br /><br />Init :<br />_Engine = Python.CreateEngine();<br />scope = _Engine.CreateScope();<br /> scope.SetVariable("I2C", localEngine);<br /> scope.SetVariable("UART", Poderosa);<br /> scope.SetVariable("dbg", _txtOut);<br /><br /> _txtBox.InteractiveObj.Add("I2C", localEngine);<br /> _txtBox.InteractiveObj.Add("UART", Poderosa);<br /> _txtBox.InteractiveObj.Add("dbg", _txtOut);<br /><br />Execute<br /><br /> _Engine.ExecuteFile(_PathToScript, scope);"</p></div><div class="topic"><a name="toc_issue_2"></a><div class="topicHeader"><span class="topicTitle">2. [New comment] Scope is not remembered after an import</span> <a href="http://ironpython.codeplex.com/workitem/30955">view online</a></div><p>User slide_o_mix has commented on the issue:</p><p>"This doesn't work in CPython either. Each module has it's own scope:<br /><br />foo.py:<br />print "x = %d" % x<br />def foo():<br /> x = globals()['x']<br /> print "x = %d" % x<br /><br /><br />script.py:<br />x = 5<br />import foo<br /><br />foo.doit()<br /><br /><br />OUTPUT:<br />Traceback (most recent call last):<br /> File "C:\Python27\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript<br /> exec codeObject in __main__.__dict__<br /> File "script.py", line 3, in <module><br /> import foo<br /> File "foo.py", line 3, in <module><br /> print "x = %d" % x<br />NameError: name 'x' is not defined<br /><br /><br />"</p></div><div class="footer"><p>You are receiving this email because you subscribed to notifications on CodePlex.</p><p>To report a bug, request a feature, or add a comment, visit <a href="http://ironpython.codeplex.com/workitem/list/basic">IronPython Issue Tracker</a>. You can <a href="https://ironpython.codeplex.com/subscriptions/workitem/project/edit">unsubscribe or change your issue notification settings</a> on CodePlex.com.</p></div></div></body></html>