<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">It happens in Importer.cs &#8211; there&#8217;s a comment saying &#8220;</span><span style="font-size:9.5pt;font-family:Consolas;color:green">// explicit
 relative import, calculate and store __package__&#8221;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">It also happens in imp.new_module, when creating the sys module, and in PythonContext.CreateBuiltinModule, but I think those are all much less interesting.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Import bugs are really tough&#8230;&nbsp; Anyone who has worked on the importer code has never looked at the CPython source code to see how it works &#8211; so there&#8217;s subtle
 issues like this.&nbsp; I&#8217;d suggest looking at CPython where it sets it and then making IronPython work the same.&nbsp;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> ironpython-users-bounces&#43;dinov=microsoft.com@python.org [mailto:ironpython-users-bounces&#43;dinov=microsoft.com@python.org]
<b>On Behalf Of </b>Slide<br>
<b>Sent:</b> Wednesday, December 14, 2011 9:03 PM<br>
<b>To:</b> ironpython-users@python.org<br>
<b>Subject:</b> [Ironpython-users] __package__<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span class="apple-style-span">Currently, I am working on implementing zipimport. I have modules being imported from egg files (very early and not a lot of testing done yet), but I notice that the __package__ attribute is not getting set
 up correctly, e.g.:</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="color:#222222">32<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">&gt;&gt;&gt; import oauth<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">&gt;&gt;&gt; dir(oauth)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">['__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__',<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">&nbsp;'__path__']<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="color:#222222">IronPython 3.0 DEBUG (3.0.0.0) on .NET 4.0.30319.237<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">&gt;&gt;&gt; import oauth<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">&gt;&gt;&gt; dir(oauth)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">['__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__path__']<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">I see in the code that there are references to __package__, but following where it it set is proving to be a bit difficult. Can someone point me in the right direction?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">slide<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#222222">Website: <a href="http://earl-of-code.com">
http://earl-of-code.com</a><o:p></o:p></span></p>
</div>
<div style="margin-top:1.5pt;outline-style:none;outline-width:initial;outline-color:initial">
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
</body>
</html>