strange behavious of the logging module?

Peter Otten __peter__ at web.de
Tue Sep 25 04:40:37 EDT 2007


Christian Meesters wrote:

> Peter Otten wrote:
> 
>> Vinay Sajip wrote:
>> 
>>> This is a known bug, and not specifically related to logging, though
>>> it sometimes manifests itself via logging:
>>> 
>>> http://bugs.python.org/issue1180193
>> 
>> Yup, thanks for looking into it.
>> 
>> Peter
> Thanks Vinay, but I am curious how issue 1180193 is related to the "bug"
> Peter and me described: I do not have any *.pyc file around. As I kept
> changing the file during development I used to call the program directly
> using a link in my PATH. Hence no *.pyc file got created at all. 

The problem is not caused by the pyc-file for your script, but by
the logging/__init__.pyc file in your python installation. You
can check if you are affected by the bug by typing

>>> logging.info.func_code.co_filename
'logging/__init__.py'
>>> logging._srcfile
'/usr/lib/python2.5/logging/__init__.py'

in the interpreter. If you get different paths like in "logging" and
"/usr/lib/python2.5/logging" in the above example you are affected.

> However, does anybody know a suggestion for a work-around?

You could try setting

logging._srcfile = logging.info.func_code.co_filename

manually, but that might break other things. Or you recreate the pyc-files
of your distribution. Again, I don't know what might break...

Peter



More information about the Python-list mailing list