From 3a8479a5838e0ad4c549d67acfdae2b9e9700e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Mon, 31 Dec 2012 03:38:39 +0100 Subject: Fixes `parser.clean()` reported in issue #16820. --- Lib/configparser.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Lib/configparser.py') diff --git a/Lib/configparser.py b/Lib/configparser.py index 06d594a431..243efec4bd 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -851,6 +851,19 @@ class RawConfigParser(MutableMapping): value_getter = lambda option: d[option] return [(option, value_getter(option)) for option in d.keys()] + def popitem(self): + """Remove a section from the parser and return it as + a (section_name, section_proxy) tuple. If no section is present, raise + KeyError. + + The section DEFAULT is never returned because it cannot be removed. + """ + for key in self.sections(): + value = self[key] + del self[key] + return key, value + raise KeyError + def optionxform(self, optionstr): return optionstr.lower() -- cgit v1.2.1