# Buggy code
def init_magics(self):
    super(ZMQInteractiveShell, self).init_magics()
    self.register_magics(KernelMagics)


# Traceback (AttributeError)
%ed
IPython will make a temporary file named: /var/folders/gw/ttdxvysn20sf7tspmk384q000000gn/T/ipython_edit_d2eA7c.py
Editing...---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-649c77c2a5b5> in <module>()
----> 1 get_ipython().magic(u'ed')

/Library/Python/2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2159         magic_name, _, magic_arg_s = arg_s.partition(' ')
2160         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2161         return self.run_line_magic(magic_name, magic_arg_s)
2162
2163     #-------------------------------------------------------------------------

/Library/Python/2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2085                 args.append(sys._getframe(stack_depth).f_locals)
2086             with self.builtin_trap:
-> 2087                 result = fn(*args)
2088             return result
2089

/Library/Python/2.7/site-packages/IPython/core/magics/code.pyc in ed(self, parameter_s)

/Library/Python/2.7/site-packages/IPython/core/magic.pyc 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 callable(arg):

/Library/Python/2.7/site-packages/IPython/core/magics/code.pyc in ed(self, parameter_s)
327     def ed(self, parameter_s=''):
328         """Alias to %edit."""
--> 329         return self.edit(parameter_s)
330
331     @skip_doctest

/Library/Python/2.7/site-packages/IPython/core/magics/code.pyc in edit(self, parameter_s, last_call)

/Library/Python/2.7/site-packages/IPython/core/magic.pyc 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 callable(arg):

/Library/Python/2.7/site-packages/IPython/core/magics/code.pyc in edit(self, parameter_s, last_call)
490             if ' ' in filename:
491                 filename = "'%s'" % filename
--> 492             self.shell.hooks.editor(filename,lineno)
493         except TryNext:
494             warn('Could not open editor')

/Library/Python/2.7/site-packages/IPython/core/hooks.pyc in __call__(self, *args, **kw)
136             #print "prio",prio,"cmd",cmd #dbg
137             try:
--> 138                 return cmd(*args, **kw)
139             except TryNext as exc:
140                 last_exc = exc

/Library/Python/2.7/site-packages/IPython/core/hooks.pyc in editor(self, filename, linenum, wait)
65     # IPython configures a default editor at startup by reading $EDITOR from
66     # the environment, and falling back on vi (unix) or notepad (win32).
---> 67     editor = self.editor
68
69     # marker for at which line to open the file (for existing objects)

AttributeError: 'ZMQInteractiveShell' object has no attribute 'editor'

# Fixed code
def init_magics(self):
    super(ZMQInteractiveShell, self).init_magics()
    self.register_magics(KernelMagics)
    self.run_line_magic("alias_magic", "ed edit")