classification
Title: configparser.ConfigParser.read() does not accept Pathlib path as a single argument.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David Ellis, berker.peksag, mcepl
Priority: normal Keywords:

Created on 2017-02-22 18:48 by David Ellis, last changed 2018-03-06 19:26 by berker.peksag. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 242 merged David Ellis, 2017-02-22 21:37
PR 432 merged berker.peksag, 2017-03-03 17:22
Messages (3)
msg288378 - (view) Author: David Ellis (David Ellis) * Date: 2017-02-22 18:48
Trying to use configparser.ConfigParser.read on a pathlib object results in a TypeError. If supplied in a list it works as expected.

Repro:
    >>> import pathlib, configparser
    >>> configparser.ConfigParser().read(pathlib.Path('some.ini'))

    TypeError: 'PosixPath' object is not iterable

The issue appears to be line 690 which checks for str before attempting to iterate and doesn't check for os.PathLike (or bytes?).

This was actually mentioned as an example where pathlib did not work here: https://bugs.python.org/issue22570
msg290326 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-03-24 23:03
New changeset 21ce65aa67f0dc63002ab0a5fb21ef921cf5279e by Berker Peksag in branch '3.6':
[3.6] bpo-29623: Make PathLike objects work with ConfigParser.read() (#242) (#432)
https://github.com/python/cpython/commit/21ce65aa67f0dc63002ab0a5fb21ef921cf5279e
msg290328 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-03-24 23:04
New changeset 85b8d01c916b482dac937b93ede1e53b1db0361c by Berker Peksag (David Ellis) in branch 'master':
bpo-29623: Make PathLike objects work with ConfigParser.read() (#242)
https://github.com/python/cpython/commit/85b8d01c916b482dac937b93ede1e53b1db0361c
History
Date User Action Args
2018-03-06 19:26:27berker.peksagsetpull_requests: - pull_request966
2018-03-06 19:26:19berker.peksagsetpull_requests: - pull_request594
2018-03-05 12:03:06mceplsetnosy: + mcepl
2017-03-31 16:36:23dstufftsetpull_requests: + pull_request966
2017-03-24 23:04:30berker.peksagsetmessages: + msg290328
2017-03-24 23:03:53berker.peksagsetmessages: + msg290326
2017-03-17 21:00:33larrysetpull_requests: + pull_request594
2017-03-03 18:25:22berker.peksagsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-03-03 17:22:12berker.peksagsetpull_requests: + pull_request358
2017-02-22 22:02:33berker.peksagsetstage: patch review
2017-02-22 21:37:50David Ellissetpull_requests: + pull_request205
2017-02-22 20:40:20berker.peksagsetnosy: + berker.peksag
2017-02-22 18:48:55David Elliscreate