Skip to content

Commit d87a60c

Browse files
committed
Safeguard _sage_getargspec_cython
1 parent 7d83063 commit d87a60c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/sage/misc/sageinspect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@ def _sage_getargspec_cython(source):
11391139
defaults=('a string', {(1, 2, 3): True}),
11401140
kwonlyargs=[], kwonlydefaults=None, annotations={})
11411141
"""
1142+
if not isinstance(source, str):
1143+
# the caller ought to ensure this, but if it forgets (e.g. passing None),
1144+
# we raise the correct exception type to avoid confusing error message
1145+
# and possible further hard-to-debug errors, see :issue:`39735`
1146+
raise TypeError
11421147
defpos = source.find('def ')
11431148
assert defpos > -1, "The given source does not contain 'def'"
11441149
s = source[defpos:].strip()

0 commit comments

Comments
 (0)