New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging : fileConfig does not check existance of the file #42682
Comments
Hi, The fileConfig method from the logging.config module Worst, if the file does not exist, the exception is Example : did@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 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 The behaviour of logging.config.fileConfig is highly I will provide a very basic path : import os
if not (os.path.file(fname)):
raise IOError('Provided filename is not existing') Didrik |
Logged In: YES i've reported it for Python 2.4 but I reproduced it on |
Logged In: YES Oups, the patch should be the following : File /usr/lib/python2.3/logging/config.py, line 61 import os
if not (os.path.isfile(fname)):
raise IOError('Provided filename is not existing') |
Logged In: YES Vinay, any comments? |
Logged In: YES I don't believe this is a logging bug. The logging code Please consider logging an issue against ConfigParser. After |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: