From: Leandro Lucarella Date: Tue, 12 Aug 2008 20:54:31 +0000 (-0300) Subject: Be aware of rst parsing errors with no line information X-Git-Url: https://git.llucax.com/software/blitiri.git/commitdiff_plain/87c41afd90655bb2c0bfb913457f73c59e0757e5 Be aware of rst parsing errors with no line information --- diff --git a/blitiri.cgi b/blitiri.cgi index c54480c..f9663b5 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -423,7 +423,7 @@ def validate_rst(rst): except SystemMessage, e: desc = e.args[0].encode('utf-8') # the error string desc = desc[9:] # remove ":" - line = int(desc[:desc.find(':')]) # get just the line number + line = int(desc[:desc.find(':')] or 0) # get the line number desc = desc[desc.find(')')+2:-1] # remove (LEVEL/N) try: desc, context = desc.split('\n', 1) @@ -1136,8 +1136,10 @@ def handle_cgi(): error = validate_rst(form_data.body) if error is not None: (line, desc, ctx) = error - form_data.body_error = 'error at line %d: %s' \ - % (line, desc) + at = '' + if line: + at = ' at line %d' % line + form_data.body_error = 'error%s: %s' % (at, desc) valid = False if valid: c = article.add_comment(form_data.author,