[issue2684] Logging Module still failing for %(filename)s, __init__

Charles Merriam report at bugs.python.org
Thu Apr 24 21:51:29 CEST 2008

New submission from Charles Merriam <charles.merriam at gmail.com>:

About same as problem in 2.4 Issue1470422 closed without a test case on
MacOS X/Python 2.4.
Also same as
and so on back for years.

What happens:

chasm at chasm-laptop:~/py$ cat x.py
import logging
from logging import debug

if __name__ == "__main__":
chasm at chasm-laptop:~/py$ python x.py

What should happen:

It should print DEBUG: x.py:3:Hello

Why it fails:

Because logging guesses that the right sys._getframe(level) should be
level 3 in __init__.py:71, in currentFrame
if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3)

What should happen:

It shouldn't guess.  In Python 2.5, the lambda might count.  In any
case, the level is off by one (4).  I suggest that it get set by walking
up the stack from until it exits the stack frame.

components: Library (Lib)
messages: 65743
nosy: CharlesMerriam
severity: normal
status: open
title: Logging Module still failing for %(filename)s, __init__
type: behavior
versions: Python 2.5

Tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list