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 Claudiu.Popa
Recipients Claudiu.Popa, lukasz.langa
Date 2013-11-10.17:16:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384103812.47.0.904880324738.issue19546@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-11-10 17:16:52Claudiu.Popasetrecipients: + Claudiu.Popa, lukasz.langa
2013-11-10 17:16:52Claudiu.Popasetmessageid: <1384103812.47.0.904880324738.issue19546@psf.upfronthosting.co.za>
2013-11-10 17:16:52Claudiu.Popalinkissue19546 messages
2013-11-10 17:16:52Claudiu.Popacreate