[Python-Dev] Python 3.4 change in importlib/__init__.py breaking cxFreeze?

Jurko Gospodnetić jurko.gospodnetic at pke.hr
Mon Mar 10 16:18:58 CET 2014


   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?

   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ć



More information about the Python-Dev mailing list