Browse files

Display source code correctly for decorated functions.

If a function is decorated with a decorator which itself has been
decorated using @decorator, currently the no source code is
displayed when '??' is used. This checks to see if the function
has a __wrapped__ attribate (added by @decorator) and appropriately
displays the source for that object.
  • Loading branch information...
1 parent ad0a4e9 commit 1b4b159ff1425bed893b3a0e1bf7a874094078b2 Ben Edwards committed Jul 14, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 IPython/core/
@@ -129,10 +129,13 @@ def getsource(obj,is_binary=False):
- is_binary: whether the object is known to come from a binary source.
This implementation will skip returning any output for binary objects, but
custom extractors may know how to meaningfully process them."""
if is_binary:
return None
+ #get source if obj was decoratred with @decorator
+ if hasattr(obj,"__wrapped__"):
+ obj = obj.__wrapped__
src = inspect.getsource(obj)
except TypeError:

0 comments on commit 1b4b159

Please sign in to comment.