Message6552

Author yoav.aner
Recipients yoav.aner
Date 2011-06-15.10:52:41
SpamBayes Score 3.902434e-13
Marked as misclassified No
Message-id <1308135161.72.0.880321211218.issue1760@psf.upfronthosting.co.za>
In-reply-to
Content
(copied from jython-dev mailing list, sorry if this is not the proper report format)

Hello,

First post to this list, so please excuse any mistakes or lack of knowledge.
I'm pretty new to jython (and perhaps not fully understand the relationship
with python etc).

One relatively small issue we've came up with is using the logging library.
Things are working fine, but when trying to add the method + line number of
the calling function to the log formatter
(e.g. %(filename)s:%(funcName)s(%(lineno)d ) then we always seemed to get
the line number of __init__.py of the logger itself...

Upon further investigation, it turned out it happens because __init__.py
only looks at .pyc and .pyo files, and ignores $py.class files. Specifically
these lines of code:

if hasattr(sys, 'frozen'): #support for py2exe
    _srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:])
elif string.lower(__file__[-4:]) in ['.pyc', '.pyo']:
    _srcfile = __file__[:-4] + '.py'
else:
    _srcfile = __file__
_srcfile = os.path.normcase(_srcfile)


If another condition is added, e.g.

elif __file__.endswith('$py.class'):
    _srcfile = __file__[:-9] + '.py'

then it fixes the problem. Not sure if this needs to be reported upstream to
python or to the jython dev... Again apologies if this is the wrong place to
report this.

Cheers
Yoav
History
Date User Action Args
2011-06-15 10:52:41yoav.anersetrecipients: + yoav.aner
2011-06-15 10:52:41yoav.anersetmessageid: <1308135161.72.0.880321211218.issue1760@psf.upfronthosting.co.za>
2011-06-15 10:52:41yoav.anerlinkissue1760 messages
2011-06-15 10:52:41yoav.anercreate