Issue 35002: Potential bug in ConfigParser.read() in python3.6, before os.Pathlike was introduced (original) (raw)

Issue35002

Created on 2018-10-16 20:23 by BNMetrics, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9921 closed BNMetrics,2018-10-16 20:32
Messages (4)
msg327842 - (view) Author: Luna Chen (BNMetrics) * Date: 2018-10-16 20:23
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()`.
msg327843 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-10-16 20:48
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'.
msg327844 - (view) Author: Luna Chen (BNMetrics) * Date: 2018-10-16 21:01
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!
msg327847 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-10-16 22:33
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
2018-10-16 21:01:47 BNMetrics set messages: +
2018-10-16 20:48:17 berker.peksag set nosy: + berker.peksagmessages: +
2018-10-16 20:32:23 BNMetrics set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest9274>
2018-10-16 20:23:37 BNMetrics create