Skip to content

Commit

Permalink
Merge pull request #67 from untitaker/no_parent
Browse files Browse the repository at this point in the history
Fix unhelpful error message when nesting invalid.
  • Loading branch information
robdennis committed Aug 26, 2014
2 parents 1b53c81 + 2956f75 commit e184b1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ def _parse(self, infile):
else:
self._handle_error("Section too nested",
NestingError, infile, cur_index)
continue

sect_name = self._unquote(sect_name)
if sect_name in parent:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_validate_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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()
Expand Down Expand Up @@ -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)

0 comments on commit e184b1c

Please sign in to comment.