<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>&nbsp;<span class="anchorMarker">&darr;</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>&nbsp;<span class="anchorMarker">&darr;</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&#35; 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&#40; can contains ref to variable in the scope &#41; the variable is no longer know.<br /><br />When looking into the code <br /><br />&#123; snipped &#125;<br />internal PythonModule&#47;&#42;&#33;&#42;&#47; CompileModule&#40;string fileName, string moduleName, SourceUnit sourceCode, ModuleOptions options, out ScriptCode scriptCode&#41; &#123;<br /><br />ContractUtils.RequiresNotNull&#40;fileName, &#34;fileName&#34;&#41;&#59;<br /><br />ContractUtils.RequiresNotNull&#40;moduleName, &#34;moduleName&#34;&#41;&#59;<br /><br />ContractUtils.RequiresNotNull&#40;sourceCode, &#34;sourceCode&#34;&#41;&#59;<br /><br />scriptCode &#61; GetScriptCode&#40;sourceCode, moduleName, options&#41;&#59;<br /><br />Scope scope &#61; scriptCode.CreateScope&#40;&#41;&#59;<br /><br />return InitializeModule&#40;fileName, &#40;&#40;PythonScopeExtension&#41;scope.GetExtension&#40;ContextId&#41;&#41;.ModuleContext, scriptCode, options&#41;&#59;<br /><br />&#125;<br /><br />&#123; end snipped &#125;<br /><br />you can see that a new scope is created, and not the initial scope is used.<br /><br />Init &#58;<br />_Engine &#61; Python.CreateEngine&#40;&#41;&#59;<br />scope &#61; _Engine.CreateScope&#40;&#41;&#59;<br />            scope.SetVariable&#40;&#34;I2C&#34;, localEngine&#41;&#59;<br />            scope.SetVariable&#40;&#34;UART&#34;, Poderosa&#41;&#59;<br />            scope.SetVariable&#40;&#34;dbg&#34;, _txtOut&#41;&#59;<br /><br />            _txtBox.InteractiveObj.Add&#40;&#34;I2C&#34;, localEngine&#41;&#59;<br />            _txtBox.InteractiveObj.Add&#40;&#34;UART&#34;, Poderosa&#41;&#59;<br />            _txtBox.InteractiveObj.Add&#40;&#34;dbg&#34;, _txtOut&#41;&#59;<br /><br />Execute<br /><br />                _Engine.ExecuteFile&#40;_PathToScript, scope&#41;&#59;"</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&#39;t work in CPython either. Each module has it&#39;s own scope&#58;<br /><br />foo.py&#58;<br />print &#34;x &#61; &#37;d&#34; &#37; x<br />def foo&#40;&#41;&#58;<br />    x &#61; globals&#40;&#41;&#91;&#39;x&#39;&#93;<br />    print &#34;x &#61; &#37;d&#34; &#37; x<br /><br /><br />script.py&#58;<br />x &#61; 5<br />import foo<br /><br />foo.doit&#40;&#41;<br /><br /><br />OUTPUT&#58;<br />Traceback &#40;most recent call last&#41;&#58;<br />  File &#34;C&#58;&#92;Python27&#92;Lib&#92;site-packages&#92;pythonwin&#92;pywin&#92;framework&#92;scriptutils.py&#34;, line 325, in RunScript<br />    exec codeObject in __main__.__dict__<br />  File &#34;script.py&#34;, line 3, in &#60;module&#62;<br />    import foo<br />  File &#34;foo.py&#34;, line 3, in &#60;module&#62;<br />    print &#34;x &#61; &#37;d&#34; &#37; x<br />NameError&#58; name &#39;x&#39; 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>