In `configparser.ConfigParser.read()`, it allows us to pass in either a single filepath or a list of filepath. As python3 supports pathlib Path. We can potentially pass in a `PosixPath` to `configparser.ConfigParser.read()`, especially when passing in a list of `PosixPath` is allowed. However, passing in a single `PosixPath` causes it to raise an exception: File "/Users/bnmetrics/workspace/cpython/Lib/configparser.py", line 694, in read for filename in filenames: TypeError: 'PosixPath' object is not iterable This issue had been addressed with later version of python by checking if the filepath passed in is an instance of `os.Pathlike`. I thought it would be nice if we can pass in a single PosixPath object to `configparser.ConfigParser.read()`.
Unless I'm missing something, you want the following snippet work in 3.6.0, right? import configparser as c import pathlib as p cp = c.ConfigParser() cp.read(p.Path('t.cfg')) t.cfg: $ cat t.cfg [Spam] foo = bar Support for PathLike objects was added in 3.6.1 (see https://github.com/python/cpython/blob/3.6/Lib/configparser.py#L691 for the latest version of the code in the 3.6 branch) and we only support the latest bugfix release of a feature release. So, in other words, we can't add a workaround for 3.6.0 in the next bugfix release of 3.6 (which will be 3.6.7) I suggest to close this as 'outdated'.
Hi Berker, Yes this workaround is mostly for python3.6.0. I have noticed my PR won't let me get to that version it seems. :( This bug seems to be present for python 3.5 as well. Would you recommend adding the fix to 3.5 instead or just simply close it? Thanks very much!
Unfortunately, we can't accept this change for 3.5 either because it's now in security-fix-only mode. See https://devguide.python.org/#status-of-python-branches for more details about the status of branches in the CPython repository. Thank you for spending time to contribute back to Python!
History
Date
User
Action
Args
2022-04-11 14:59:07
admin
set
github: 79183
2018-10-16 22:33:36
berker.peksag
set
messages: + components: + Library (Lib)
2018-10-16 21:37:14
BNMetrics
set
status: open -> closedresolution: out of datestage: patch review -> resolved