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ć

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to