This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Logging Module still failing for %(filename)s, __init__
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: CharlesMerriam, vinay.sajip
Priority: normal Keywords:

Created on 2008-04-24 19:51 by CharlesMerriam, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg65743 - (view) Author: Charles Merriam (CharlesMerriam) Date: 2008-04-24 19:51
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@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@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.
msg65744 - (view) Author: Charles Merriam (CharlesMerriam) Date: 2008-04-24 19:53
oops, last line should be "exits the stack frames for the logging
module.  This should be a once-per-program-execution event"

Hmm.. tracker should have a preview button.
msg65776 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2008-04-25 10:27
Can you confirm whether this problem occurs even after deleting all .pyc
and .pyo files, including in the Python library folders and your
application folders? Also, which specific platform is this happening on?

On your installation, is the line number 1327 the last line in
logging/__init__.py?
msg65809 - (view) Author: Charles Merriam (CharlesMerriam) Date: 2008-04-25 20:33
In my installation, line 1327 is within the logging.debug()  function,
specifically at the
call to  apply(root.debug, (msg,)+args, kwargs)

chasm@chasm-laptop:~/py$ rm *.pyc
chasm@chasm-laptop:~/py$ python x.py
DEBUG:logging/__init__.py:1327:Hello
chasm@chasm-laptop:~/py$ uname -a
Linux chasm-laptop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC
2008 i686 GNU/Linux
chasm@chasm-laptop:~/py$ python -V
Python 2.5.1

-and then-
chasm@chasm-laptop:/usr/lib/python2.5$ sudo rm -rf *.pyc *.pyo */*.pyc
*/*.pyo */*/*.pyc */*/*.pyo
chasm@chasm-laptop:/usr/lib/python2.5$ cd ~/py
chasm@chasm-laptop:~/py$ python x.py
DEBUG:x.py:7:Hello
chasm@chasm-laptop:~/py$

So it was somewhere in the library brunches.  The uname -a translates
to "Kbuntu Gutsy".  Python, and extras like pylint, coverage, and
nose, were installed via Kbuntu's package manager.

-- Charles

On Fri, Apr 25, 2008 at 3:27 AM, Vinay Sajip <report@bugs.python.org> wrote:
>
>  Vinay Sajip <vinay_sajip@yahoo.co.uk> added the comment:
>
>  Can you confirm whether this problem occurs even after deleting all .pyc
>  and .pyo files, including in the Python library folders and your
>  application folders? Also, which specific platform is this happening on?
>
>  On your installation, is the line number 1327 the last line in
>  logging/__init__.py?
>
>  ----------
>  assignee:  -> vsajip
>  nosy: +vsajip
>
>
>
>  __________________________________
>  Tracker <report@bugs.python.org>
>  <http://bugs.python.org/issue2684>
>  __________________________________
>
msg65840 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2008-04-26 10:54
This is not a logging bug, but rather due to the circumstance that
.pyc/.pyo files do not correctly point to the source files that produced
them. There is another issue about this (#1180193) .

Closing this, as it's not a logging issue.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46936
2008-04-26 10:55:44vinay.sajipsetstatus: open -> closed
resolution: not a bug
2008-04-26 10:54:44vinay.sajipsetmessages: + msg65840
2008-04-25 20:33:39CharlesMerriamsetmessages: + msg65809
2008-04-25 10:27:50vinay.sajipsetassignee: vinay.sajip
messages: + msg65776
nosy: + vinay.sajip
2008-04-24 19:53:52CharlesMerriamsetmessages: + msg65744
2008-04-24 19:51:28CharlesMerriamcreate