This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ConfigParser.read silently fails if filenames argument is a byte string
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David Ellis, berker.peksag, cryvate, lukasz.langa, vxgmichel
Priority: normal Keywords:

Created on 2017-08-30 14:15 by vxgmichel, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3420 merged vxgmichel, 2017-09-07 12:06
Messages (5)
msg301026 - (view) Author: Vincent Michel (vxgmichel) * Date: 2017-08-30 14:15
Calling `config_parser.read` with `'test'` is equivalent to:

    config_parser.read(['test'])

while calling `config_parser.read` with `b'test'` is treated as:

    config_parser.read([116, 101, 115, 116])

which means python will try to open the file descriptors 101, 115 and 116.

I don't know if byte path should be supported, but this is probably not the expected behavior.

The method code: https://github.com/python/cpython/blob/master/Lib/configparser.py#L678-L702
msg301149 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2017-09-01 19:48
Good catch. Supporting bytes passed as a path is a reasonable request since the builtin `open()` supports this, too. Go ahead and create a pull request! We only need to modify line 690 to also list `bytes`.
msg301192 - (view) Author: David Ellis (David Ellis) * Date: 2017-09-03 14:02
This is related to the issue I'd brought up previously here so closing this would also close that issue: http://bugs.python.org/issue29627

I did originally attempt to add support for bytes in PR where I added support for Path-like objects: 
https://github.com/python/cpython/pull/242 but I was asked to take it back out.
msg305421 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-02 12:47
New changeset e314853d57450b2b9523157eebd405289a795a0e by Berker Peksag (Vincent Michel) in branch 'master':
bpo-31307: Make ConfigParser.read() accept bytes objects (GH-3420)
https://github.com/python/cpython/commit/e314853d57450b2b9523157eebd405289a795a0e
msg305422 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-02 12:49
Thanks! I went ahead and merged PR 3420 since Łukasz (the configparser maintainer) has accepted the idea.
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75488
2017-11-02 12:49:05berker.peksagsetstatus: open -> closed
type: behavior -> enhancement
messages: + msg305422

resolution: fixed
stage: resolved
2017-11-02 12:47:06berker.peksagsetnosy: + berker.peksag
messages: + msg305421
2017-09-07 12:06:27vxgmichelsetpull_requests: + pull_request3417
2017-09-05 17:52:56lukasz.langalinkissue29627 superseder
2017-09-03 14:02:16David Ellissetnosy: + David Ellis
messages: + msg301192
2017-09-01 19:48:23lukasz.langasetmessages: + msg301149
2017-08-31 12:01:28cryvatesetnosy: + cryvate
2017-08-30 15:32:59r.david.murraysetnosy: + lukasz.langa
2017-08-30 14:15:47vxgmichelcreate