Skip to content

Commit b9903f9

Browse files
committed
RF - guard against syntax errors parsing input for strings
1 parent d6f0fdc commit b9903f9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nisext/py3builder.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
""" distutils utilities for porting to python 3 within 2-compatible tree """
22

33
from __future__ import with_statement
4+
5+
import sys
46
import re
57
import ast
68
from . import codegen
@@ -175,7 +177,13 @@ def doctest_markup(in_lines):
175177
if expr == 'bytes':
176178
# Any strings on the given line are byte strings
177179
pre, mid, post = INDENT_SPLITTER.match(line).groups()
178-
res = byter(mid)
180+
try:
181+
res = byter(mid)
182+
except:
183+
err = sys.exc_info()[1]
184+
print('Error "%s" parsing "%s"; skipping' %
185+
(err, mid))
186+
continue
179187
res = pre + res + post
180188
else:
181189
# If expr starts with 'replace', implies "line.replace"

0 commit comments

Comments
 (0)