[issue18260] configparser: TypeError occurs when handling errors in files with binary names

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 56c1227f21f5 by Łukasz Langa in branch '3.3':
Fixed issue #18260: configparser TypeError on source name specified as bytes
http://hg.python.org/cpython/rev/56c1227f21f5

New changeset 06e70937364b by Łukasz Langa in branch 'default':
Merged fix for issue #18260 from 3.3
http://hg.python.org/cpython/rev/06e70937364b

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18260] configparser: TypeError occurs when handling errors in files with binary names

2013-06-23 Thread Łukasz Langa

Łukasz Langa added the comment:

1. Duplicate sections and options are consciously reported as errors now. This 
is a documented backwards-incompatible change [1]_. If you wish to revert to 
previous behaviour, you can set strict=False on parser creation.

2. It's really just a coincidence that specifying the filename as bytes worked 
in this case before on Python 3. That being said, it is indeed an unfortunate 
regression and was fixed in 56c1227f21f5 for 3.3 and 06e70937364b for 3.4. As a 
workaround for Python versions  3.3.3 you can specify the source name as a 
Unicode string (e.g. `read_file(f, source=path_str)`.


.. [1] 
http://docs.python.org/3/library/configparser.html#customizing-parser-behaviour

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18260] configparser: TypeError occurs when handling errors in files with binary names

2013-06-18 Thread Arfrever Frehtes Taifersar Arahesis

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 rep...@bugs.python.org
http://bugs.python.org/issue18260
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com