[Patches] [ python-Patches-1447410 ] logging: findCaller() sometimes raises AttributeError

SourceForge.net noreply at sourceforge.net
Thu Mar 16 08:08:10 CET 2006


Patches item #1447410, was opened at 2006-03-10 10:12
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1447410&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Kevin J Bluck (kbluck)
Assigned to: Vinay Sajip (vsajip)
Summary: logging: findCaller() sometimes raises AttributeError

Initial Comment:
I am invoking the logging.log() function via the C API,
using PyObject_CallFunction(). I have found that
sometimes (not always) the findCaller() function raises
this AttributeError:

AttributeError: 'NoneType' object has no attribute 'f_code'
  File "C:\Program
Files\Python\Lib\logging\__init__.py", line 1052, in
findCaller
    co = f.f_code
  File "C:\Program
Files\Python\Lib\logging\__init__.py", line 1078, in _log
    fn, lno, func = self.findCaller()
  File "C:\Program
Files\Python\Lib\logging\__init__.py", line 1043, in log
    apply(self._log, (level, msg, args), kwargs)
  File "C:\Program
Files\Python\Lib\logging\__init__.py", line 1319, in log
    apply(root

It appears that sometimes, currentframe() is returning
None.

Attached is a patch for logging/__init__.py which
guards against this possibility. Patch is generated
against recent SVN head revision 42958.


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2006-03-15 23:08

Message:
Logged In: YES 
user_id=33168

Vinay, should this be backported?

----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2006-03-15 04:46

Message:
Logged In: YES 
user_id=308438

A version of this patch is in SVN revision 43048.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1447410&group_id=5470


More information about the Patches mailing list