X Tutup
Skip to content

Commit dab1ccb

Browse files
committed
revert to shortening messages thrown by inspect.getsource before raising
1 parent 1c218a1 commit dab1ccb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bpython/repl.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,15 @@ def get_source_of_current_name(self):
600600
obj = self.get_object(line)
601601
if obj is None:
602602
raise NameError("%s is not defined" % line)
603-
return inspect.getsource(obj) #throws an exception that we'll catch
603+
try:
604+
inspect.getsource(obj)
605+
except TypeError, e:
606+
msg = e.msg
607+
if "built-in" in msg:
608+
msg.split(">")
609+
raise TypeError("Cannot access source of <built-in function %s>" % self.current_line)
610+
else:
611+
raise TypeError("No source code found for %s" % self.current_line)
604612

605613
def set_docstring(self):
606614
self.docstring = None

0 commit comments

Comments
 (0)
X Tutup