From 68b2599088c2ffc34f18da9c0fb4d5e32c7a25ac 2014-04-18 05:12:56 From: George Titsworth Date: 2014-04-18 05:12:56 Subject: [PATCH] Reworking object look up code to use existing inspect functionality. --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 32d7f44..98b924a 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -3157,23 +3157,10 @@ class InteractiveShell(SingletonConfigurable): raise ValueError("'%s' is a directory, not a regular file." % target) if search_ns: - obj = None - parts = target.split(".") - try: - if len(parts) >= 1: - obj = self.user_ns[parts[0]] - - for new_obj in parts[1:]: - obj = getattr(obj, new_obj) - - if obj: - - code = oinspect.getsource(obj) - return code - except Exception: - # Either the value wa't in th user_ns or the objects could - # not be inspected. It still might load below, so just pass. - pass + # Inspect namespace to load object source + object_info = self.object_inspect(target, detail_level=1) + if object_info['found'] and object_info['source']: + return object_info['source'] try: # User namespace codeobj = eval(target, self.user_ns)