[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
http://mail.python.org/pipermail/python-bugs-list/2004-July/024111.html
and so on back for years.

What happens:

chasm at chasm-laptop:~/py$ cat x.py
import logging
logging.basicConfig(level=logging.DEBUG,
                   
format="%(levelname)s:%(pathname)s:%(lineno)d:%(message)s")
from logging import debug

if __name__ == "__main__":
    debug("Hello")
chasm at chasm-laptop:~/py$ python x.py
DEBUG:logging/__init__.py:1327:Hello

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>
<http://bugs.python.org/issue2684>
__________________________________


More information about the Python-bugs-list mailing list