ipython/ipython — Issue #1258: Magic %paste error
Author: wesm
Created: 2012-01-12 21:00:35+00:00
State: open

off git master

```

In [2]: paste
from StringIO import StringIO

text = """a,b,c,d
one,1,2,3
one,1,2,3
,1,2,3
one,1,2,3
,1,2,3
,1,2,3
one,1,2,3
two,1,2,3"""

data = StringIO(text)
## -- End pasted text --
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/home/wesm/code/pandas/ in ()
----> 1 get_ipython().magic(u'paste ')

/home/wesm/code/repos/ipython/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
1996 self._magic_locals = sys._getframe(1).f_locals
1997 with self.builtin_trap:
-> 1998 result = fn(magic_args)
1999 # Ensure we're not keeping object references around:

2000 self._magic_locals = {}

/home/wesm/code/repos/ipython/IPython/frontend/terminal/interactiveshell.pyc in magic_paste(self, parameter_s)
651 write("## -- End pasted text --\n")
652
--> 653 store_or_execute(self.shell, block, name)
654
655 # Class-level: add a '%cls' magic only on Windows

/home/wesm/code/repos/ipython/IPython/frontend/terminal/interactiveshell.pyc in store_or_execute(shell, block, name)
93 # Dedent and prefilter so what we store matches what is executed by

94 # run_cell.

---> 95 b = shell.prefilter(textwrap.dedent(block))
96
97 if name:

/home/wesm/code/repos/ipython/IPython/core/prefilter.pyc in prefilter_lines(self, lines, continue_prompt)
355 if len(llines) > 1:
356 out = '\n'.join([self.prefilter_line(line, lnum>0)
--> 357 for lnum, line in enumerate(llines) ])
358 else:
359 out = self.prefilter_line(llines[0], continue_prompt)

/home/wesm/code/repos/ipython/IPython/core/prefilter.pyc in prefilter_line(self, line, continue_prompt)
332 return normal_handler.handle(line_info)
333
--> 334 prefiltered = self.prefilter_line_info(line_info)
335 # print "prefiltered line: %r" % prefiltered

336 return prefiltered

/home/wesm/code/repos/ipython/IPython/core/prefilter.pyc in prefilter_line_info(self, line_info)
272 # print "prefilter_line_info: ", line_info

273 handler = self.find_handler(line_info)
--> 274 return handler.handle(line_info)
275
276 def find_handler(self, line_info):

/home/wesm/code/repos/ipython/IPython/core/prefilter.pyc in handle(self, line_info)
801 esc = line_info.esc
802 continue_prompt = line_info.continue_prompt
--> 803 obj = line_info.ofind(self)['obj']
804 #print 'pre <%s> ifun <%s> rest <%s>' % (pre,ifun,the_rest) # dbg

805

KeyError: 'obj'
```