-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Unhelpful error message from logging.config.FileConfig can be improved #103606
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
Comments
Hi, @vsajip can I try to fix this? |
@Agent-Hellboy It's an open project, no preliminary assignment is required. The only thing you need is to follow the contributor's manual at https://devguide.python.org/ where conventions and processes are described. |
okay, sure |
Hi @arhadthedev Line 71 in d1e4917
It uses configparser to parse the configuration files which suppresses the OSError but it returns an empty list if the file is not presentLine 665 in d1e4917
I will raise a PR which will raise ValueError that the file is not present and will try to include a test for the same |
Wouldn't it be simpler to use e.g. |
Because of the easier to ask for forgiveness than permission principle with the very import os
# violates EAFP coding style
if os.path.exists("file.txt"):
os.unlink("file.txt") |
Yes, but the "file not found" message/ |
okay, I will raise FileNotFound before giving the file to the config parser Line 63 in 6be7aee
why should I try to parse a file which is not present
|
…pythonGH-103628) (cherry picked from commit 152227b)
I left some comments on the merged PR... ValueError isn't the right exception to use for things external to the process not related to the variable value itself. I suggest RuntimeError if you don't have your own Error exception class. |
sure @gpshead, I will raise a PR |
…4701) (this adjusts new code) raise RuntimeError if provided config file is invalid or empty, not ValueError.
thanks! |
Feature or enhancement
If a configuration file does not exist, the error raised by
logging.config.fileConfig
doesn't say that the file doesn't exist, instead suggesting that the file has an invalid format. This should be improved so that the correct error message is provided.Pitch
The improved error message will guide a user to an error such as a typo in the filename more quickly. See for example this question.
Linked PRs
The text was updated successfully, but these errors were encountered: