[issue21709] logging.__init__ assumes that __file__ is always set

Vinay Sajip report at bugs.python.org
Wed Jun 11 12:32:35 CEST 2014


Vinay Sajip added the comment:

> _srcfile is only used to identify the caller's stack frame

Not quite. It's also used to indicate whether findCaller() should be called at all: setting it to None avoids calling findCaller(), which might be desirable in some performance-sensitive scenarios.

So if you mean "just call _get_module_filename() instead of accessing _srcFile", that won't do. If you mean "set _srcFile to the return value of _get_module_filename()", that might work, if I e.g. move the _srcFile definition to after addLevelName (say) and do just

_srcFile = addLevelName.__code__.co_filename

How does that sound?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21709>
_______________________________________


More information about the Python-bugs-list mailing list