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.

Author Arfrever
Recipients Arfrever, lukasz.langa
Date 2013-06-19.04:18:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371615488.35.0.189174506667.issue18260@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-06-19 04:18:08Arfreversetrecipients: + Arfrever, lukasz.langa
2013-06-19 04:18:08Arfreversetmessageid: <1371615488.35.0.189174506667.issue18260@psf.upfronthosting.co.za>
2013-06-19 04:18:08Arfreverlinkissue18260 messages
2013-06-19 04:18:07Arfrevercreate