Skip to content

Commit 62cb39d

Browse files
authored
Merge pull request #91 from ehebert/fix-parser-error-message
BUG: Make docscrape ParseError Python 3 compatible.
2 parents 13ae28b + 436c55a commit 62cb39d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def is_empty(self):
9191

9292
class ParseError(Exception):
9393
def __str__(self):
94-
message = self.message
94+
message = self.args[0]
9595
if hasattr(self, 'docstring'):
9696
message = "%s in %r" % (message, self.docstring)
9797
return message

numpydoc/tests/test_docscrape.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
import jinja2
88

9-
from numpydoc.docscrape import NumpyDocString, FunctionDoc, ClassDoc
9+
from numpydoc.docscrape import (
10+
NumpyDocString,
11+
FunctionDoc,
12+
ClassDoc,
13+
ParseError
14+
)
1015
from numpydoc.docscrape_sphinx import SphinxDocString, SphinxClassDoc
1116
from nose.tools import *
1217

@@ -635,6 +640,23 @@ def test_see_also():
635640
elif func == 'class_j':
636641
assert desc == ['fubar', 'foobar']
637642

643+
644+
def test_see_also_parse_error():
645+
text = (
646+
"""
647+
z(x,theta)
648+
649+
See Also
650+
--------
651+
:func:`~foo`
652+
""")
653+
with assert_raises(ParseError) as err:
654+
NumpyDocString(text)
655+
assert_equal(
656+
str(r":func:`~foo` is not a item name in '\n z(x,theta)\n\n See Also\n --------\n :func:`~foo`\n '"),
657+
str(err.exception)
658+
)
659+
638660
def test_see_also_print():
639661
class Dummy(object):
640662
"""

0 commit comments

Comments
 (0)