Commit 0b712334 authored by Yuya Nishihara's avatar Yuya Nishihara

wconfig: fix AttributeError on translation of pure ParsingError (fixes #3353)

Unlike MissingSectionHeaderError, ParsingError keeps lineno in errors list.

branch : stable
parent f36d6679d52d
......@@ -226,12 +226,20 @@ def check_read_write():
def check_read_write_parse_error():
def check_read_write_missing_section_header_error():
c = newwconfig()
s = 'bar = baz' # missing header'foo', fp=StringIO(s))
def check_read_write_parsing_error():
c = newwconfig()
s = '[foo]\n:bar = baz' # Mercurial can parse it but INIConfig can't'foo', fp=StringIO(s))
def check_write_after_dict_setitem():
c = newwconfig({'': 'x'})
......@@ -187,9 +187,15 @@ class _wconfig(object):
# TODO: optionxformvalue isn't used by INIConfig ?
return INIConfig(fp=fp, optionxformvalue=None)
except ConfigParser.ParsingError, err:
except ConfigParser.MissingSectionHeaderError, err:
raise error.ParseError(err.message.splitlines()[0],
'%s:%d' % (err.filename, err.lineno))
except ConfigParser.ParsingError, err:
if err.errors:
loc = '%s:%d' % (err.filename, err.errors[0][0])
loc = err.filename
raise error.ParseError(err.message.splitlines()[0], loc)
if not self._readfiles:
return newini()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment