classification
Title: funcName in logging module for python 2.6
Type: crash Stage:
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amarco, ezio.melotti, r.david.murray, vinay.sajip
Priority: normal Keywords:

Created on 2013-01-02 22:37 by amarco, last changed 2013-01-03 11:16 by vinay.sajip. This issue is now closed.

Messages (6)
msg178859 - (view) Author: Alejandro Marco Ramos (amarco) Date: 2013-01-02 22:37
hi, when use the param 'funcName' in the logging module (version 0.4.9.6 for python 2.6) the module crash. Researching in the code (__init__.py) i see that the code for get the function name is in method '_log' in the class 'Logger'. The function 'findCaller()' returns in the last value the name of the function (in the variable name 'func'), but this variable is not present in the caller function for create a 'record' object (in this case 'makeRecord'). I added code to fix this but i like that review this bug.
msg178860 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-01-02 23:01
Can you provide some code to reproduce the issue and/or the traceback you got?  Note that 2.6 only receives security fixes, so it won't be fixed there -- but it can be fixed in 2.7/3.2/3.3/3.x if they are affected.
msg178862 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-02 23:08
I wonder if this is related to issue 16778.
msg178863 - (view) Author: Alejandro Marco Ramos (amarco) Date: 2013-01-02 23:20
is not related to 16778
msg178920 - (view) Author: Alejandro Marco Ramos (amarco) Date: 2013-01-03 07:48
In response to msg178860.

When use the module logging and in the definition of the format string appear '%(funcName)s' the module crash.
(Extract):
File "/Library/Python/2.6/site-packages/logging-0.4.9.6-py2.6.egg/logging/__init__.py", line 724, in emit
    msg = self.format(record)
  File "/Library/Python/2.6/site-packages/logging-0.4.9.6-py2.6.egg/logging/__init__.py", line 610, in format
    return fmt.format(record)
  File "/Library/Python/2.6/site-packages/logging-0.4.9.6-py2.6.egg/logging/__init__.py", line 403, in format
    s = self._fmt % record.__dict__
KeyError: 'funcName'

The object 'record' not contain attribute 'funcName' and line 403 (s = self._fmt % record.__dict__) crash.
msg178935 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2013-01-03 11:16
You are apparently not using the logging in stdlib, but the older, standalone logging package intended to be used in versions of Python older than 2.3 - note the presence of "site-packages/logging-0.4.9.6-py2.6.egg" in the traceback.

If you are using Python 2.6, you don't need the standalone logging-0.4.9.6, as the logging in the stdlib is more up to date (as you've discovered).
History
Date User Action Args
2013-01-03 11:16:56vinay.sajipsetstatus: open -> closed
resolution: not a bug
messages: + msg178935
2013-01-03 07:48:58amarcosetmessages: + msg178920
2013-01-02 23:20:39amarcosetmessages: + msg178863
2013-01-02 23:08:02r.david.murraysetnosy: + vinay.sajip, r.david.murray
messages: + msg178862
2013-01-02 23:01:32ezio.melottisetnosy: + ezio.melotti
messages: + msg178860
2013-01-02 22:37:22amarcocreate