<br><br><div class="gmail_quote">On Thu, May 3, 2012 at 12:15 PM, Barry Warsaw <span dir="ltr"><<a href="mailto:barry@python.org" target="_blank">barry@python.org</a>></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>
>So, to the people not wanting to set __file__, that (probably) won't fly<br>
>because it has been documented for years that built-in modules are the only<br>
>things that don'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'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'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>
>Or we at least need to explain to people how to tell the difference in a<br>
</div>>backwards-compatible fashion.<br>
<br>
Definitely, and I think that would be fine to include in PEP 420.<br>
<div class="im"><br>
>So I would have said that had experience with the stdlib not big me on<br>
>this. In my situation, the trace module was checking file, and if __file__<br>
>didn't contain "<frozen>" or "<doctest" it would try to read it as a path,<br>
>and then error out if it couldn't open the file. Now I updated it to<br>
>startswith('<') and endswith('>'), but I wonder how many people made a<br>
>similar whitelist approach. And while having __file__ to None or<br>
>non-existent will take about the same amount of time to fix, it is less<br>
>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't remind me about "arbitrary and underdocumented" 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>