[issue31307] ConfigParser.read silently fails if filenames argument is a byte string
David Ellis added the comment: 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. -- nosy: +David Ellis ___ Python tracker <http://bugs.python.org/issue31307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29627] configparser.ConfigParser.read() has undocumented/unexpected behaviour when given a bytestring path.
New submission from David Ellis: Related: https://github.com/python/cpython/pull/242 https://bugs.python.org/issue29623 In the discussion over my PR for bpo-29623 it became clear that bytestring paths were also unsupported and it was suggested that that should be a separate issue (currently the PR adds checks for both types). There is some possible odd behaviour as when given a bytestring path the method attempts to open the integer file descriptors for each character in the bytestring. This will most likely fail silently but if it does find an actual file descriptor it will attempt to read and then close the file. Example from the discussion on the PR: >>> import os >>> import configparser >>> k = os.open('/home/david/develop/cpython/Lib/test/cfgparser.1', os.O_RDONLY) >>> k 3 >>> c = configparser.ConfigParser() >>> c.read(b'\x03') [3] >>> list(c) ['DEFAULT', 'Foo Bar'] >>> os.close(k) # File has already been closed OSError: [Errno 9] Bad file descriptor Currently bytestrings do work correctly when provided as part of a list. -- components: Library (Lib) messages: 288394 nosy: David Ellis priority: normal severity: normal status: open title: configparser.ConfigParser.read() has undocumented/unexpected behaviour when given a bytestring path. type: behavior versions: Python 3.5, Python 3.6, Python 3.7 ___ Python tracker <http://bugs.python.org/issue29627> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.
Changes by David Ellis : -- pull_requests: +205 ___ Python tracker <http://bugs.python.org/issue29623> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.
New submission from David Ellis: 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 -- components: Library (Lib) messages: 288378 nosy: David Ellis priority: normal severity: normal status: open title: configparser.ConfigParser.read() does not accept Pathlib path as a single argument. type: behavior versions: Python 3.6, Python 3.7 ___ Python tracker <http://bugs.python.org/issue29623> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com