[Python-Dev] Python 3.4 change in importlib/__init__.py breaking cxFreeze?
Nick Coghlan
ncoghlan at gmail.com
Mon Mar 10 22:15:08 CET 2014
On 11 Mar 2014 01:44, "Brett Cannon" <bcannon at gmail.com> wrote:
>
>
>
> On Mon Mar 10 2014 at 11:41:27 AM, Jurko Gospodnetić <
jurko.gospodnetic at pke.hr> wrote:
>>
>> Hi Nick.
>>
>> On 10.3.2014. 14:25, Nick Coghlan wrote:> What is supposed to happen
>> when that code gets loaded from a ZIP archive?
>> >
>> > __file__ is expected to always be set (including when loaded from a
>> > zipfile - in that case it's the zipfile name concatenated with the
>> > path within the zip file). If it isn't set, there's a buggy loader
>> > involved somewhere that isn't setting it properly.
>>
>> I don't recall seeing that ever explicitly stated. For that matter,
>> Python 3.4.0rc3 documentation explicitly states:
>>
>> > __file__ is optional. If set, this attribute’s value must be a string.
>> > The import system may opt to leave __file__ unset if it has no
>> > semantic meaning (e.g. a module loaded from a database).
>>
>> and:
>>
>> > Ultimately, the loader is what makes use of __file__ and/or
__cached__.
>>
>> Or is this some rule specific to the importlib/__init__.py stdlib
module?
>
>
> 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.
Yeah, I was thinking of the 3.4 changes to ensure that various *other*
module attributes are always set, even in __main__ (and frozen modules).
My apologies for the misinformation - I should have waited until I had a
chance to look it up properly.
Cheers,
Nick.
>
> -Brett
>
>>
>>
>> As I recall, I first learned that not all loaded modules need to have
>> their __file__ attribute set by researching a failure in some package
>> when installed as a zipped-egg using setuptools. Admittedly though, that
>> was some old setuptools version.
>>
>> Best regards,
>> Jurko Gospodnetić
>>
>> _______________________________________________
>> Python-Dev mailing list
>> Python-Dev at python.org
>> https://mail.python.org/mailman/listinfo/python-dev
>> Unsubscribe:
https://mail.python.org/mailman/options/python-dev/brett%40python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140311/05dd0e89/attachment-0001.html>
More information about the Python-Dev
mailing list