[ python-Bugs-1378755 ] logging : fileConfig does not check existance of the file

SourceForge.net noreply at sourceforge.net
Mon Dec 12 15:26:10 CET 2005


Bugs item #1378755, was opened at 2005-12-12 15:24
Message generated for change (Settings changed) made by dpinte
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1378755&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: Python Library
Group: Python 2.4
Status: Open
>Resolution: Works For Me
Priority: 5
Submitted By: Didrik Pinte (dpinte)
Assigned to: Nobody/Anonymous (nobody)
Summary: logging : fileConfig does not check existance of the file

Initial Comment:
Hi,

The fileConfig method from the logging.config module
does not check for the existance of the config file
before trying to load it.

Worst, if the file does not exist, the exception is
totally unrelated to the file.

Example : 

did at geru-itea:~/$ python
Python 2.3.5 (#2, Nov 20 2005, 16:40:39)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on
linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> from logging import config
>>> config.fileConfig('')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/logging/config.py", line 68,
in fileConfig
    flist = cp.get("formatters", "keys")
  File "/usr/lib/python2.3/ConfigParser.py", line 505,
in get
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'formatters'


It is really important that the exception is correctly
reported.

In fact, the problem seems to be here : 

/usr/lib/python2.3/ConfigParser.py, line 258

        for filename in filenames:
            try:
                fp = open(filename)
            except IOError:
                continue
            self._read(fp, filename)


The documentation of the read method says "Files that
cannot be opened are silently ignored;".

The behaviour of logging.config.fileConfig is highly
related to the user actions. He must be informed of the
fact that the logging system have not opened its file.

I will provide a very basic path :
File /usr/lib/python2.3/logging/config.py, line 61
-------------------------------------------------
import os
if not (os.path.file(fname)):
   raise IOError('Provided filename is not existing')
-------------------------------------------------

Didrik

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

Comment By: Didrik Pinte (dpinte)
Date: 2005-12-12 15:25

Message:
Logged In: YES 
user_id=970259

i've reported it for Python 2.4 but I reproduced it on
Python 2.3.

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

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


More information about the Python-bugs-list mailing list