@@ -125,6 +125,7 @@ def match_utf8(encoding):
125125 'default_encoding' : None ,
126126 'unrepr' : False ,
127127 'write_empty_values' : False ,
128+ 'invalid' : False
128129}
129130
130131# this could be replaced if six is used for compatibility, or there are no
@@ -1145,7 +1146,7 @@ def __init__(self, infile=None, options=None, configspec=None, encoding=None,
11451146 interpolation = True , raise_errors = False , list_values = True ,
11461147 create_empty = False , file_error = False , stringify = True ,
11471148 indent_type = None , default_encoding = None , unrepr = False ,
1148- write_empty_values = False , _inspec = False ):
1149+ write_empty_values = False , invalid = False , _inspec = False ):
11491150 """
11501151 Parse a config file or create a config file object.
11511152
@@ -1167,7 +1168,7 @@ def __init__(self, infile=None, options=None, configspec=None, encoding=None,
11671168 'create_empty' : create_empty , 'file_error' : file_error ,
11681169 'stringify' : stringify , 'indent_type' : indent_type ,
11691170 'default_encoding' : default_encoding , 'unrepr' : unrepr ,
1170- 'write_empty_values' : write_empty_values }
1171+ 'write_empty_values' : write_empty_values , 'invalid' : invalid }
11711172
11721173 if options is None :
11731174 options = _options
@@ -1318,6 +1319,7 @@ def _initialise(self, options=None):
13181319 self .BOM = False
13191320 self .newlines = None
13201321 self .write_empty_values = options ['write_empty_values' ]
1322+ self .invalid = options ['invalid' ]
13211323 self .unrepr = options ['unrepr' ]
13221324
13231325 self .initial_comment = []
@@ -1600,9 +1602,10 @@ def _parse(self, infile):
16001602 # so it should be a valid ``key = value`` line
16011603 mat = self ._keyword .match (line )
16021604 if mat is None :
1603- self ._handle_error (
1604- 'Invalid line ({0!r}) (matched as neither section nor keyword)' .format (line ),
1605- ParseError , infile , cur_index )
1605+ if not self .invalid :
1606+ self ._handle_error (
1607+ 'Invalid line ({0!r}) (matched as neither section nor keyword)' .format (line ),
1608+ ParseError , infile , cur_index )
16061609 else :
16071610 # is a keyword value
16081611 # value will include any inline comment
0 commit comments