From 2956f7548169820c5439abd0c503274a09a65870 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 25 Aug 2014 23:38:50 +0200 Subject: Fix unhelpful error message when nesting invalid. See https://github.com/geier/khal/issues/105 --- configobj.py | 1 + tests/test_validate_errors.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configobj.py b/configobj.py index 4499e60..ba886e8 100644 --- a/configobj.py +++ b/configobj.py @@ -1603,6 +1603,7 @@ class ConfigObj(Section): else: self._handle_error("Section too nested", NestingError, infile, cur_index) + continue sect_name = self._unquote(sect_name) if sect_name in parent: diff --git a/tests/test_validate_errors.py b/tests/test_validate_errors.py index f96b613..644dfb3 100644 --- a/tests/test_validate_errors.py +++ b/tests/test_validate_errors.py @@ -2,7 +2,7 @@ import os import pytest -from configobj import ConfigObj, get_extra_values, ParseError +from configobj import ConfigObj, get_extra_values, ParseError, NestingError from validate import Validator @pytest.fixture() @@ -70,3 +70,10 @@ def test_invalid_lines_with_percents(tmpdir, specpath): ini.write('extra: %H:%M\n') with pytest.raises(ParseError): conf = ConfigObj(str(ini), configspec=specpath, file_error=True) + + +def test_no_parent(tmpdir, specpath): + ini = tmpdir.join('config.ini') + ini.write('[[haha]]') + with pytest.raises(NestingError): + conf = ConfigObj(str(ini), configspec=specpath, file_error=True) -- cgit v1.2.1