[issue16820] configparser.ConfigParser.clean and .update bugs

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d5c45089df2d by Łukasz Langa in branch '3.3':
Misc/NEWS updated to tell about #14590 and #16820
http://hg.python.org/cpython/rev/d5c45089df2d

New changeset 7938847b2641 by Łukasz Langa in branch '3.2':
Misc/NEWS updated to tell about #16820
http://hg.python.org/cpython/rev/7938847b2641

--

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2013-01-01 Thread Łukasz Langa

Łukasz Langa added the comment:

Breaking section order when using `__setitem__` was a bug and as such was fixed 
in 3.2.4 and 3.3.1.

In the DEFAULTSECT case above someone could potentially use the broken 
behaviour as a feature so that change was only made for 3.3.1+. In the section 
order case there is no such controversy.

--
resolution: rejected -> fixed
status: open -> closed

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6f0cee62f0c6 by Łukasz Langa in branch '3.2':
configparser: preserve section order when using `__setitem__` (issue #16820)
http://hg.python.org/cpython/rev/6f0cee62f0c6

New changeset 2f5320497017 by Łukasz Langa in branch '3.3':
Null-merged 3.2 section order preservation fix when using `__setitem__` (issue
http://hg.python.org/cpython/rev/2f5320497017

New changeset 27b698395d35 by Łukasz Langa in branch 'default':
Null-merged 3.2 section order preservation fix when using `__setitem__` (issue
http://hg.python.org/cpython/rev/27b698395d35

--

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f580342b63d8 by Łukasz Langa in branch '3.3':
configparser: preserve section order when using `__setitem__` (issue #16820)
http://hg.python.org/cpython/rev/f580342b63d8

New changeset a758f561a280 by Łukasz Langa in branch 'default':
Merged section order preservation fix when using `__setitem__` (issue #16820)
http://hg.python.org/cpython/rev/a758f561a280

--

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2013-01-01 Thread Łukasz Langa

Łukasz Langa added the comment:

This is a fair point. Stay tuned.

--

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-31 Thread Wolfgang Scherer

Wolfgang Scherer added the comment:

Thanks, works for me.

I only noted the discrepancy and did not give it much thought.
I will just implement a merge method on top of read_dict.
That gives me all options that could be desired :).

However, after implementing the entire compatibility layer, I found one more 
issue:

Using self.remove_section() changes the section order during an update.
I would prefer that the section be cleared instead of removed in order to 
preserve the section order. Since OrderedDict does indeed preserve the key 
order during update, I think that this does not violate the Mapping Protocol.

If this is not desired, just go ahead and close the issue.

See also attached example bug_configparser_update_order.py:

OrderedDict does not change the order of keys upon .update():

>>> od = OrderedDict((('section1', {}), ('section2', {})))

>>> list(od.keys())
['section1', 'section2']

>>> od.update((('section1', {}), ('section3', {})))

>>> list(od.keys())
['section1', 'section2', 'section3']

But ConfigParser changes the order of sections upon .update():

>>> cfg = configparser.ConfigParser()
>>> cfg.update((('section1', {}), ('section2', {})))

>>> cfg.sections()
['section1', 'section2']

>>> cfg.update((('section1', {}), ('section3', {})))

>>> cfg.sections()
['section2', 'section1', 'section3']

--
resolution: fixed -> rejected
status: closed -> open
Added file: http://bugs.python.org/file28514/bug_configparser_update_order.py

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-31 Thread Łukasz Langa

Łukasz Langa added the comment:

For the record, the bug that caused the following to be equivalent:

  parser['DEFAULT'] = {'option': 'value'} 
  parser['DEFAULT'].update({'option': 'value'})

has been fixed for 3.3.1+ only. This way it's going to be easier for users to 
reason about the fix ("it was broken in 3.2.0 - 3.3.0").

Note that the bug only affected __setitem__ on the default section.

--
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-31 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 459a23083b66 by Łukasz Langa in branch '3.3':
Fixes `__setitem__` on parser['DEFAULT'] reported in issue #16820.
http://hg.python.org/cpython/rev/459a23083b66

New changeset f6fb5a5748f0 by Łukasz Langa in branch 'default':
Merged `parser['DEFAULT'].__setitem__` fix (issue #16820) from 3.3.
http://hg.python.org/cpython/rev/f6fb5a5748f0

--

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-30 Thread Łukasz Langa

Łukasz Langa added the comment:

Thanks for your report, Wolfgang. The `clean()` method is now fixed. The
`update()` situation is more complicated, however.

The mapping protocol defines that

mapping.update({'a': 'b', 'c': 'd'})

and

mapping.update(a='b', c='d')

are equivalent to

mapping['a'] = 'b'
mapping['c'] = 'd'

For `configparser` we decided that setting a section on a parser is
a destructive operation (e.g. it overwrites previous options). If the user
finds this undesirable, she can either use `parser['section'].update()` or
`parser.read_dict()` like you suggested.

The bug here is that __setitem__ for the DEFAULTSECT should also clear options
previously set on this section.

--
versions: +Python 3.3

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset dc5adc08f1a8 by Łukasz Langa in branch '3.2':
Fixes `parser.clean()` reported in issue #16820.
http://hg.python.org/cpython/rev/dc5adc08f1a8

New changeset 4fc2fea807e6 by Łukasz Langa in branch '3.3':
Merged `parser.clean()` fix (issue #16820) from 3.2.
http://hg.python.org/cpython/rev/4fc2fea807e6

New changeset c6f9bc5a0cf1 by Łukasz Langa in branch 'default':
Merged `parser.clean()` fix (issue #16820) from 3.2 through 3.3.
http://hg.python.org/cpython/rev/c6f9bc5a0cf1

--
nosy: +python-dev

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-30 Thread Łukasz Langa

Changes by Łukasz Langa :


--
assignee:  -> lukasz.langa

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-30 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue16820] configparser.ConfigParser.clean and .update bugs

2012-12-30 Thread Wolfgang Scherer

New submission from Wolfgang Scherer:

configparser.ConfigParser.clean() always fails:

>>> cfg = configparser.ConfigParser()
>>> if not hasattr(configparser.ConfigParser, 'clear'):
... configparser.ConfigParser.clear = configparser_clear_compat
>>> cfg.clear() #doctest: +ELLIPSIS
Traceback (most recent call last):
...
ValueError: Cannot remove the default section.

configparser.ConfigParser.update() overwrites all sections except DEFAULT 
instead of updating them.

See attached test file-

--
components: Library (Lib)
files: bug_configparser.py
messages: 178588
nosy: wolfmanx
priority: normal
severity: normal
status: open
title: configparser.ConfigParser.clean and .update bugs
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file28493/bug_configparser.py

___
Python tracker 

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