Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%pdef failing on python3 #1914

Closed
jstenar opened this issue Jun 11, 2012 · 4 comments
Closed

%pdef failing on python3 #1914

jstenar opened this issue Jun 11, 2012 · 4 comments
Labels
Milestone

Comments

@jstenar
Copy link
Member

jstenar commented Jun 11, 2012

This is on windows
On python2:

In [1]: def a(): pass

In [2]: %pdef a
 a()

On Python3:

In [5]: def a(): pass

In [6]: %pdef a
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\python\ipydevel\VENV\åäö\error3.py in <module>()
----> 1 get_ipython().magic('pdef a')

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\interactiveshell.py in magic(self, arg_s)
   2140         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2141         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2142         return self.run_line_magic(magic_name, magic_arg_s)
   2143
   2144     #-------------------------------------------------------------------------

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
   2066                 args.append(sys._getframe(stack_depth).f_locals)
   2067             with self.builtin_trap:
-> 2068                 result = fn(*args)
   2069             return result
   2070

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\magics\namespace.py in pdef(self, parameter_s, namespaces)

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\magic.py in <lambda>(f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192
    193         if isinstance(arg, collections.Callable):

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\magics\namespace.py in pdef(self, parameter_s, namespaces)
     80           urllib.urlopen(url, data=None, proxies=None)
     81         """
---> 82         self.shell._inspect('pdef',parameter_s, namespaces)
     83
     84     @line_magic

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\interactiveshell.py in _inspect(self, meth, oname, namespaces, **kw)
   1477                 pmethod(info.obj, oname, formatter, info, **kw)
   1478             else:
-> 1479                 pmethod(info.obj, oname)
   1480         else:
   1481             print('Object `%s` not found.' % oname)

C:\python\ipydevel\VENV\py32\lib\site-packages\ipython-0.13.dev-py3.2.egg\IPython\core\oinspect.py in pdef(self, obj, oname)
    356             header = self.__head('Class constructor information:\n')
    357             obj = obj.__init__
--> 358         elif type(obj) is types.InstanceType:
    359             obj = obj.__call__
    360

AttributeError: 'module' object has no attribute 'InstanceType'
@jstenar
Copy link
Member Author

jstenar commented Jun 11, 2012

This failure was seen on master 2287b38

@fperez
Copy link
Member

fperez commented Jun 11, 2012

OK, confirming also on linux. We need a test added to the suite first that causes the problem, before adding a fix.

@takluyver, since this is only visible on py3, to first order I'll leave it in your hands. Let us know if you need help, of course!

@takluyver
Copy link
Member

Just about to investigate it.

@fperez
Copy link
Member

fperez commented Jun 11, 2012

Awesome, thx.

takluyver added a commit to takluyver/ipython that referenced this issue Jun 11, 2012
jenshnielsen pushed a commit to jenshnielsen/ipython that referenced this issue Jun 11, 2012
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
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants