Skip to content

Commit d3f2c91

Browse files
committed
make getting filename python2 compatible
1 parent 5b03f4e commit d3f2c91

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: numpydoc/numpydoc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
116116
try:
117117
doc = SphinxDocString(pydoc.getdoc(obj))
118118
except ValueError as e:
119-
filename = obj.__code__.co_filename
119+
try:
120+
filename = inspect.getsourcefile(obj)
121+
except TypeError:
122+
filename = None
120123
raise ValueError(str(e) + " in {}:{}".format(filename, name))
121124
sig = doc['Signature'] or getattr(obj, '__text_signature__', None)
122125
if sig:

0 commit comments

Comments
 (0)