New submission from Jurko Gospodnetić:

Python 3.4 introduced a change to Lib/importlib/__init__.py that added the 
following code to it:

> else:
>     # importlib._bootstrap is the built-in import, ensure we don't create
>     # a second copy of the module.
>     _bootstrap.__name__ = 'importlib._bootstrap'
>     _bootstrap.__package__ = 'importlib'
>     _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')
>     sys.modules['importlib._bootstrap'] = _bootstrap

When attempting to use cxFreeze on a project, using Python 3.4. we ran into a 
problem with '__file__' identifier not being defined.

I believe this is a bug since the code expects the module loaded from 
importlib/__init__.py to always have a __file__ identifier set.


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__.


A possible fix would be to skip setting the _bootstrap.__file__ attribute if 
the current module does not have a __file__ attribute set.


I hope this can be resolved before the 3.4 final release or it will not be 
possible to use cxFreeze with Python 3.4 without additional workarounds in 
cxFreeze.

Best regards,
  Jurko Gospodnetić

----------
components: Interpreter Core, Library (Lib)
messages: 213047
nosy: Jurko.Gospodnetić
priority: normal
severity: normal
status: open
title: importlib/__init__.py can not be loaded without __file__ - breaks 
cxFreeze
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20884>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to