[New-bugs-announce] [issue18260] configparser: TypeError occurs when handling errors in files with binary names
Arfrever Frehtes Taifersar Arahesis
report at bugs.python.org
Wed Jun 19 06:18:08 CEST 2013
New submission from Arfrever Frehtes Taifersar Arahesis:
TypeError occurs when handling errors in files with binary names.
configparser.* exceptions are expected.
This regression was introduced in Python 3.2.
$ cat /tmp/test1
[section]
[section]
$ cat /tmp/test2
[section]
option = value
option = value
$ python3.1 -c 'import configparser; configparser.ConfigParser().readfp(open("/tmp/test1"))'
$ python3.1 -c 'import configparser; configparser.ConfigParser().readfp(open("/tmp/test2"))'
$ python3.1 -c 'import configparser; configparser.ConfigParser().readfp(open(b"/tmp/test1"))'
$ python3.1 -c 'import configparser; configparser.ConfigParser().readfp(open(b"/tmp/test2"))'
$ python3.4 -c 'import configparser; configparser.ConfigParser().read_file(open("/tmp/test1"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.4/configparser.py", line 708, in read_file
self._read(f, source)
File "/usr/lib64/python3.4/configparser.py", line 1061, in _read
lineno)
configparser.DuplicateSectionError: While reading from /tmp/test1 [line 2]: section 'section' already exists
$ python3.4 -c 'import configparser; configparser.ConfigParser().read_file(open("/tmp/test2"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.4/configparser.py", line 708, in read_file
self._read(f, source)
File "/usr/lib64/python3.4/configparser.py", line 1087, in _read
fpname, lineno)
configparser.DuplicateOptionError: While reading from /tmp/test2 [line 3]: option 'option' in section 'section' already exists
$ python3.4 -c 'import configparser; configparser.ConfigParser().read_file(open(b"/tmp/test1"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.4/configparser.py", line 708, in read_file
self._read(f, source)
File "/usr/lib64/python3.4/configparser.py", line 1061, in _read
lineno)
File "/usr/lib64/python3.4/configparser.py", line 202, in __init__
Error.__init__(self, "".join(msg))
TypeError: sequence item 1: expected str instance, bytes found
$ python3.4 -c 'import configparser; configparser.ConfigParser().read_file(open(b"/tmp/test2"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.4/configparser.py", line 708, in read_file
self._read(f, source)
File "/usr/lib64/python3.4/configparser.py", line 1087, in _read
fpname, lineno)
File "/usr/lib64/python3.4/configparser.py", line 228, in __init__
Error.__init__(self, "".join(msg))
TypeError: sequence item 1: expected str instance, bytes found
----------
assignee: lukasz.langa
components: Library (Lib)
keywords: 3.2regression
messages: 191443
nosy: Arfrever, lukasz.langa
priority: normal
severity: normal
status: open
title: configparser: TypeError occurs when handling errors in files with binary names
versions: Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18260>
_______________________________________
More information about the New-bugs-announce
mailing list