[issue19546] configparser leaks implementation detail

Claudiu.Popa report at bugs.python.org
Sun Nov 10 18:16:52 CET 2013


New submission from Claudiu.Popa:

Various exceptions raised by configparser module leaks implementation detail, by chaining KeyErrors, as seen below:

Python 3.4.0a4+ (default:0aa2aedc6a21+, Nov  5 2013, 17:10:42)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import configparser
>>> parser = configparser.ConfigParser()
>>> parser.remove_option('Section1', 'an_int')
Traceback (most recent call last):
  File "/tank/libs/cpython/Lib/configparser.py", line 935, in remove_option
    sectdict = self._sections[section]
KeyError: 'Section1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tank/libs/cpython/Lib/configparser.py", line 937, in remove_option
    raise NoSectionError(section)
configparser.NoSectionError: No section: 'Section1'
>>>

There are multiple places where this happens: using basic and extended interpolation, using .options to retrieve non-existent options, using .get or .remove_options for non-existent options/sections. The attached patch tries to fixes all those issues by suppressing the initial exception.

----------
components: Library (Lib)
files: configparser.patch
keywords: patch
messages: 202538
nosy: Claudiu.Popa, lukasz.langa
priority: normal
severity: normal
status: open
title: configparser leaks implementation detail
versions: Python 3.4
Added file: http://bugs.python.org/file32564/configparser.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19546>
_______________________________________


More information about the Python-bugs-list mailing list