##// END OF EJS Templates
Catch clipboard exception in magic_paste and print error message
Matt Cottingham -
Show More
@@ -34,7 +34,7 b' from IPython.testing.skipdoctest import skip_doctest'
34 34 from IPython.utils import py3compat
35 35 from IPython.utils.terminal import toggle_set_term_title, set_term_title
36 36 from IPython.utils.process import abbrev_cwd
37 from IPython.utils.warn import warn
37 from IPython.utils.warn import warn, error
38 38 from IPython.utils.text import num_ini_spaces
39 39 from IPython.utils.traitlets import Int, CBool, Unicode
40 40
@@ -611,9 +611,16 b' class TerminalInteractiveShell(InteractiveShell):'
611 611 if opts.has_key('r'):
612 612 self._rerun_pasted()
613 613 return
614
615 text = self.shell.hooks.clipboard_get()
616 block = self._strip_pasted_lines_for_code(text.splitlines())
614 try:
615 text = self.shell.hooks.clipboard_get()
616 block = self._strip_pasted_lines_for_code(text.splitlines())
617 except TryNext as clipboard_exc:
618 message = getattr(clipboard_exc, 'args')
619 if message:
620 error(message)
621 else:
622 error('Could not get text from the clipboard.')
623 return
617 624
618 625 # By default, echo back to terminal unless quiet mode is requested
619 626 if not opts.has_key('q'):
General Comments 0
You need to be logged in to leave comments. Login now