[New-bugs-announce] [issue21709] logging.__init__ assumes that __file__ is always set
Marc-Andre Lemburg
report at bugs.python.org
Tue Jun 10 23:15:54 CEST 2014
New submission from Marc-Andre Lemburg:
It is not when freezing the logging package, so any use of the logging package fails:
>>> import logging
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<pyrun>/importlib/_bootstrap.py", line 2237, in _find_and_load
File "<pyrun>/importlib/_bootstrap.py", line 2226, in _find_and_load_unlocked
File "<pyrun>/importlib/_bootstrap.py", line 1200, in _load_unlocked
File "<pyrun>/importlib/_bootstrap.py", line 1129, in _exec
File "<pyrun>/importlib/_bootstrap.py", line 1359, in exec_module
File "<pyrun>/logging/__init__.py", line 61, in <module>
NameError: name '__file__' is not defined
This is the code in question:
#
# _srcfile is used when walking the stack to check when we've got the first
# caller stack frame.
#
if hasattr(sys, 'frozen'): #support for py2exe
_srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:])
else:
_srcfile = __file__
_srcfile = os.path.normcase(_srcfile)
Note the special case for py2exe. But this doesn't really help, since frozen modules don't have the __file__ attribute set - at least not when generated with Tools/freeze.
PS: This is with Python 3.4.1.
----------
components: Interpreter Core, Library (Lib)
messages: 220196
nosy: lemburg
priority: normal
severity: normal
status: open
title: logging.__init__ assumes that __file__ is always set
versions: Python 3.4, Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21709>
_______________________________________
More information about the New-bugs-announce
mailing list