Skip to content

Commit

Permalink
Merge pull request scipy#16239 from WarrenWeckesser/nonprintable-line
Browse files Browse the repository at this point in the history
MAINT: tools: Add more output to a refguide-check error message.
  • Loading branch information
ev-br authored May 22, 2022
2 parents 6299b30 + f94570c commit 62f75fa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/refguide_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def compare(all_dict, others, names, module_name):

return only_all, only_ref, missing


def is_deprecated(f):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("error")
Expand All @@ -282,6 +283,7 @@ def is_deprecated(f):
pass
return False


def check_items(all_dict, names, deprecated, others, module_name, dots=True):
num_all = len(all_dict)
num_ref = len(names)
Expand Down Expand Up @@ -447,10 +449,11 @@ def check_rest(module, names, dots=True):
traceback.format_exc()))
continue

m = re.search("([\x00-\x09\x0b-\x1f])", text)
m = re.search(".*?([\x00-\x09\x0b-\x1f]).*", text)
if m:
msg = ("Docstring contains a non-printable character %r! "
"Maybe forgot r\"\"\"?" % (m.group(1),))
msg = ("Docstring contains a non-printable character "
f"{m.group(1)!r} in the line\n\n{m.group(0)!r}\n\n"
"Maybe forgot r\"\"\"?")
results.append((full_name, False, msg))
continue

Expand Down Expand Up @@ -552,6 +555,7 @@ def report_failure(self, out, test, example, got):
return doctest.DocTestRunner.report_failure(self, out, test,
example, got)


class Checker(doctest.OutputChecker):
obj_pattern = re.compile(r'at 0x[0-9a-fA-F]+>')
vanilla = doctest.OutputChecker()
Expand Down Expand Up @@ -647,7 +651,6 @@ def check_output(self, want, got, optionflags):
else:
return self.check_output(want_again, got_again, optionflags)


# ... and defer to numpy
try:
return self._do_check(a_want, a_got)
Expand Down

0 comments on commit 62f75fa

Please sign in to comment.