Instantiating classes without __init__ function causes kernel to crash #447

meawoppl opened this Issue May 17, 2011 · 3 comments


None yet

2 participants

In [1]: class A(object): pass
In [2]: A()
Out[2]: <__main__.A at 0x924806c>
In [3]: class A(): pass
In [4]: A()

(Heartbeat down window)  Error trace:

AttributeError                            Traceback (most recent call last)
/media/Dropbox/git-repos/pypline/ in ()

/usr/local/lib/python2.6/dist-packages/IPython/zmq/ipkernel.pyc in main()
--> 681     start_kernel(namespace, kernel)

/usr/local/lib/python2.6/dist-packages/IPython/zmq/entry_point.pyc in start_kernel(namespace=Namespace(colors=None, hb=42345, ip='',...ue, pub=39708, pylab=None, req=53755, xrep=54374), kernel=)
    148     # Start the kernel mainloop.
--> 149     kernel.start()

/usr/local/lib/python2.6/dist-packages/IPython/zmq/ipkernel.pyc in start(self=)
    169         while True:
    170             time.sleep(self._poll_interval)
--> 171             self.do_one_iteration()
        global stdin = undefined
        global stdout = undefined
        global stderr = undefined
        global optional = undefined
        global default = undefined
        global None = undefined
    173     def record_ports(self, xrep_port, pub_port, req_port, hb_port):

/usr/local/lib/python2.6/dist-packages/IPython/zmq/ipkernel.pyc in do_one_iteration(self=)
    153             logger.error("UNKNOWN MESSAGE TYPE:" +str(msg))
    154         else:
--> 155             handler(ident, msg)
    157         # Check whether we should exit, in case the incoming message set the

/usr/local/lib/python2.6/dist-packages/IPython/zmq/ipkernel.pyc in object_info_request(self=, ident='662dab72-d0d4-4ff0-af1c-7e1ca6439e55', parent={'content': {'oname': 'A'}, 'header': {'msg_id': 9, 'session': '662dab72-d0d4-4ff0-af1c-7e1ca6439e55', 'username': 'meawoppl'}, 'msg_type': 'object_info_request', 'parent_header': {}})
    319     def object_info_request(self, ident, parent):
--> 320         object_info =['content']['oname'])
    321         # Before we send this object over, we scrub it for JSON usage
    322         oinfo = json_clean(object_info)

/usr/local/lib/python2.6/dist-packages/IPython/core/interactiveshell.pyc in object_inspect(self=, oname='A')
   1292             info = self._object_find(oname)
   1293             if info.found:
-> 1294                 return, oname, info=info)
   1295             else:
   1296                 return oinspect.object_info(name=oname, found=False)

/usr/local/lib/python2.6/dist-packages/IPython/core/oinspect.pyc in info(self=, obj=, oname='A', formatter=None, info={'obj': , ', 'namespace': 'Interactive', 'ismagic': False}, detail_level=0)
    816         if inspect.isclass(obj):
--> 817             callable_obj = obj.__init__
    818         elif callable(obj):
    819             callable_obj = obj
AttributeError: class A has no attribute '__init__'

OK, I see. New style classes always have an __init__ method, old style classes don't. I'll look at it.

@takluyver takluyver was assigned May 17, 2011
@takluyver takluyver added a commit to takluyver/ipython that referenced this issue May 17, 2011
@takluyver takluyver Tweak so it doesn't fail on old style classes. Added…
… test.

Closes gh-447

Made pull request #449


Merged the fix, see commit 12af0e2.

@takluyver takluyver closed this May 17, 2011
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@takluyver takluyver Tweak so it doesn't fail on old style classes. Added…
… test.

Closes gh-447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment