[issue35448] ConfigParser .read() - handling of nonexistent files

STINNER Victor report at bugs.python.org
Mon Oct 28 12:04:27 EDT 2019


STINNER Victor <vstinner at python.org> added the comment:

> I would expect that this basic usage is very popular. If the file doesn't exist, the normal usage pattern fails in a confusing way: (...)

Well, the configparser is well defined. As you wrote: "If a file named in filenames cannot be opened, that file will be ignored."

You can check if the file exists or not by checking read() result:

"read(): (...) returning a list of filenames which were successfully parsed."
https://docs.python.org/dev/library/configparser.html#configparser.ConfigParser.read

I suggest to close this issue as "not a bug".

--

For me, a better option would be to be able to pass an open file to configparser. So the caller can decide how to handle the open() error.

----------
nosy: +vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35448>
_______________________________________


More information about the Python-bugs-list mailing list