File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -591,19 +591,16 @@ def get_source_of_current_name(self):
591
591
"""Return the source code of the object which is bound to the
592
592
current name in the current input line. Return `None` if the
593
593
source cannot be found."""
594
- try :
595
- obj = self .current_func
594
+ obj = self .current_func
595
+ if obj is None :
596
+ line = self .current_line
597
+ if line == "" :
598
+ raise ValueError ("Cannot get source of an empty string" )
599
+ if inspection .is_eval_safe_name (line ):
600
+ obj = self .get_object (line )
596
601
if obj is None :
597
- line = self .current_line
598
- if inspection .is_eval_safe_name (line ):
599
- obj = self .get_object (line )
600
- if obj is None :
601
- return None
602
- source = inspect .getsource (obj )
603
- except (AttributeError , IOError , NameError , TypeError ):
604
- return None
605
- else :
606
- return source
602
+ raise NameError ("%s is not defined" % line )
603
+ return inspect .getsource (obj ) #throws an exception that we'll catch
607
604
608
605
def set_docstring (self ):
609
606
self .docstring = None
You can’t perform that action at this time.
0 commit comments