Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/configobj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def match_utf8(encoding):
'default_encoding': None,
'unrepr': False,
'write_empty_values': False,
'invalid': False
}

# this could be replaced if six is used for compatibility, or there are no
Expand Down Expand Up @@ -1151,7 +1152,7 @@ def __init__(self, infile=None, options=None, configspec=None, encoding=None,
interpolation=True, raise_errors=False, list_values=True,
create_empty=False, file_error=False, stringify=True,
indent_type=None, default_encoding=None, unrepr=False,
write_empty_values=False, _inspec=False):
write_empty_values=False, invalid=False, _inspec=False):
"""
Parse a config file or create a config file object.

Expand All @@ -1173,7 +1174,7 @@ def __init__(self, infile=None, options=None, configspec=None, encoding=None,
'create_empty': create_empty, 'file_error': file_error,
'stringify': stringify, 'indent_type': indent_type,
'default_encoding': default_encoding, 'unrepr': unrepr,
'write_empty_values': write_empty_values}
'write_empty_values': write_empty_values, 'invalid':invalid}

if options is None:
options = _options
Expand Down Expand Up @@ -1328,6 +1329,7 @@ def _initialise(self, options=None):
self.BOM = False
self.newlines = None
self.write_empty_values = options['write_empty_values']
self.invalid = options['invalid']
self.unrepr = options['unrepr']

self.initial_comment = []
Expand Down Expand Up @@ -1603,9 +1605,10 @@ def _parse(self, infile):
# so it should be a valid ``key = value`` line
mat = self._keyword.match(line)
if mat is None:
self._handle_error(
'Invalid line ({!r}) (matched as neither section nor keyword)'.format(line),
ParseError, infile, cur_index)
if not self.invalid:
self._handle_error(
'Invalid line ({!r}) (matched as neither section nor keyword)'.format(line),
ParseError, infile, cur_index)
else:
# is a keyword value
# value will include any inline comment
Expand Down