<br><br><div>On Mon Mar 10 2014 at 11:41:27 AM, Jurko Gospodnetić <<a href="mailto:jurko.gospodnetic@pke.hr">jurko.gospodnetic@pke.hr</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Nick.<br>
<br>
On 10.3.2014. 14:25, Nick Coghlan wrote:> What is supposed to happen<br>
when that code gets loaded from a ZIP archive?<br>
><br>
> __file__ is expected to always be set (including when loaded from a<br>
> zipfile - in that case it's the zipfile name concatenated with the<br>
> path within the zip file). If it isn't set, there's a buggy loader<br>
> involved somewhere that isn't setting it properly.<br>
<br>
I don't recall seeing that ever explicitly stated. For that matter,<br>
Python 3.4.0rc3 documentation explicitly states:<br>
<br>
> __file__ is optional. If set, this attribute’s value must be a string.<br>
> The import system may opt to leave __file__ unset if it has no<br>
> semantic meaning (e.g. a module loaded from a database).<br>
<br>
and:<br>
<br>
> Ultimately, the loader is what makes use of __file__ and/or __cached__.<br>
<br>
Or is this some rule specific to the importlib/__init__.py stdlib module?<br></blockquote><div><br></div><div>No, Nick was mistaken and Barry's response is accurate: __file__ is optional and left off when it doesn't make any sense. Since importlib._bootstrap is a frozen module by default it doesn't have __file__ set.</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>
As I recall, I first learned that not all loaded modules need to have<br>
their __file__ attribute set by researching a failure in some package<br>
when installed as a zipped-egg using setuptools. Admittedly though, that<br>
was some old setuptools version.<br>
<br>
Best regards,<br>
Jurko Gospodnetić<br>
<br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" target="_blank">https://mail.python.org/<u></u>mailman/options/python-dev/<u></u>brett%40python.org</a><br>
</blockquote>