<br><br><div class="gmail_quote">On Thu, May 3, 2012 at 12:15 PM, Barry Warsaw <span dir="ltr">&lt;<a href="mailto:barry@python.org" target="_blank">barry@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On May 03, 2012, at 10:48 AM, Brett Cannon wrote:<br>
<br>
&gt;So, to the people not wanting to set __file__, that  (probably) won&#39;t fly<br>
&gt;because it has been documented for years that built-in modules are the only<br>
&gt;things that don&#39;t define __file__.<br>
<br>
</div>Okay, but *why* is this the rule, other than that PEP 302 says it?  IOW, PEP<br>
302 doesn&#39;t give much of a rationale for the rule, and I suspect it just<br>
reflected the reality back in 2002.<br></blockquote><div><br></div><div>Exactly. I am willing to be that historically it&#39;s just because that was the only way you could tell what was or was not a built-in module.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
&gt;Or we at least need to explain to people how to tell the difference in a<br>
</div>&gt;backwards-compatible fashion.<br>
<br>
Definitely, and I think that would be fine to include in PEP 420.<br>
<div class="im"><br>
&gt;So I would have said that had experience with the stdlib not big me on<br>
&gt;this. In my situation, the trace module was checking file, and if __file__<br>
&gt;didn&#39;t contain &quot;&lt;frozen&gt;&quot; or &quot;&lt;doctest&quot; it would try to read it as a path,<br>
&gt;and then error out if it couldn&#39;t open the file. Now I updated it to<br>
&gt;startswith(&#39;&lt;&#39;) and endswith(&#39;&gt;&#39;), but I wonder how many people made a<br>
&gt;similar whitelist approach. And while having __file__ to None or<br>
&gt;non-existent will take about the same amount of time to fix, it is less<br>
&gt;prone to silly whitelisting like what the trace module had.<br>
<br>
</div>See what I mean about arbitrary and underdocumented? :)<br></blockquote><div><br></div><div>I don&#39;t remind me about &quot;arbitrary and underdocumented&quot; when it comes to the import system. =P</div><div><br>

</div><div>-Brett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
-Barry<br>
<br>_______________________________________________<br>
Import-SIG mailing list<br>
<a href="mailto:Import-SIG@python.org">Import-SIG@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/import-sig" target="_blank">http://mail.python.org/mailman/listinfo/import-sig</a><br>
<br></blockquote></div><br>