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: error when logging message
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: kuiper, r.david.murray
Priority: normal Keywords:

Created on 2012-10-31 00:09 by kuiper, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
__init__.py kuiper, 2012-10-31 00:09 toplevel module for astronomical calculations
Messages (5)
msg174247 - (view) Author: Tom Kuiper (kuiper) Date: 2012-10-31 00:09
This error comes from the logging module when a message is logged, but only when I also import another module which does use logging at all:

Traceback (most recent call last):
  File "/usr/lib/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 437, in format
    if string.find(self._fmt,"%(asctime)") >= 0:
  File "/usr/lib/python2.6/string.py", line 361, in find
    return s.find(*args)
AttributeError: 'int' object has no attribute 'find'

The module source is attached.  Some of it's submodules were built with f2py.
msg174251 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-10-31 00:29
Do none of those submodules import logging?

It is unlikely that this is a Python bug.  Somewhere _fmt is getting set to an integer.  The way to prove this one way or another is to start deleting things until you find the code that is triggering the issue.
msg174252 - (view) Author: Tom Kuiper (kuiper) Date: 2012-10-31 00:36
Give me a few moments to dig further.  I may have found the submodule 
culprit.  Checking.

Tom

On 10/30/2012 05:29 PM, R. David Murray wrote:
> R. David Murray added the comment:
>
> Do none of those submodules import logging?
>
> It is unlikely that this is a Python bug.  Somewhere _fmt is getting set to an integer.  The way to prove this one way or another is to start deleting things until you find the code that is triggering the issue.
>
> ----------
> nosy: +r.david.murray
> resolution:  ->  invalid
> stage:  ->  committed/rejected
> status: open ->  pending
>
> _______________________________________
> Python tracker<report@bugs.python.org>
> <http://bugs.python.org/issue16368>
> _______________________________________
>
msg174253 - (view) Author: Tom Kuiper (kuiper) Date: 2012-10-31 00:44
On 10/30/2012 05:29 PM, R. David Murray wrote:
> R. David Murray added the comment:
>
> Do none of those submodules import logging?
>
> It is unlikely that this is a Python bug.  Somewhere _fmt is getting set to an integer.  The way to prove this one way or another is to start deleting things until you find the code that is triggering the issue.
>    
After tortuous digging I found a subsubmodule that does this:

import logging
logging_options = [logging.DEBUG,
                    logging.INFO,
                    logging.WARNING,
                    logging.ERROR,
                    logging.CRITICAL]
logging_level = logging_options[2]
logging.basicConfig(format=logging_level)

Commenting out that last line fixed the problem.  I've now cleared out 
all the code shown here. Thanks for the tip.

Tom
> ----------
> nosy: +r.david.murray
> resolution:  ->  invalid
> stage:  ->  committed/rejected
> status: open ->  pending
>
> _______________________________________
> Python tracker<report@bugs.python.org>
> <http://bugs.python.org/issue16368>
> _______________________________________
>
msg174254 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-10-31 01:37
Yep, that would do it.  format is supposed to be a format string.
History
Date User Action Args
2022-04-11 14:57:37adminsetgithub: 60572
2012-10-31 01:37:11r.david.murraysetstatus: open -> closed

messages: + msg174254
2012-10-31 00:44:59kuipersetmessages: + msg174253
2012-10-31 00:36:19kuipersetstatus: pending -> open

messages: + msg174252
2012-10-31 00:29:38r.david.murraysetstatus: open -> pending

nosy: + r.david.murray
messages: + msg174251

resolution: not a bug
stage: resolved
2012-10-31 00:09:13kuipercreate