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 <[email protected]>
<http://bugs.python.org/issue29627>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com