Skip to content

Commit

Permalink
Merge pull request ipython#1917 from takluyver/i1914
Browse files Browse the repository at this point in the history
Fix for %pdef on Python 3

A nice simple one - types.InstanceType is for old style classes, so we don't check against it on Python 3.

closes ipython#1914
  • Loading branch information
minrk committed Jun 11, 2012
2 parents 967ce49 + 08402f9 commit 01d7b93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IPython/core/oinspect.py
Expand Up @@ -354,7 +354,7 @@ def pdef(self, obj, oname=''):
if inspect.isclass(obj):
header = self.__head('Class constructor information:\n')
obj = obj.__init__
elif type(obj) is types.InstanceType:
elif (not py3compat.PY3) and type(obj) is types.InstanceType:
obj = obj.__call__

output = self._getdef(obj,oname)
Expand Down
5 changes: 5 additions & 0 deletions IPython/core/tests/test_oinspect.py
Expand Up @@ -283,3 +283,8 @@ def getdoc(self):
nt.assert_equal(oinspect.getdoc(a), "standard docstring")
nt.assert_equal(oinspect.getdoc(b), "custom docstring")
nt.assert_equal(oinspect.getdoc(c), "standard docstring")

def test_pdef():
# See gh-1914
def foo(): pass
inspector.pdef(foo, 'foo')

0 comments on commit 01d7b93

Please sign in to comment.