dcaee6
To: vim_dev@googlegroups.com
dcaee6
Subject: Patch 7.4.084
dcaee6
Fcc: outbox
dcaee6
From: Bram Moolenaar <Bram@moolenaar.net>
dcaee6
Mime-Version: 1.0
dcaee6
Content-Type: text/plain; charset=UTF-8
dcaee6
Content-Transfer-Encoding: 8bit
dcaee6
------------
dcaee6
dcaee6
Patch 7.4.084
dcaee6
Problem:    Python: interrupt not being properly discarded. (Yggdroot Chen)
dcaee6
Solution:   Discard interrupt in VimTryEnd. (ZyX)
dcaee6
Files:      src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
dcaee6
            src/testdir/test87.in, src/testdir/test87.ok
dcaee6
dcaee6
dcaee6
*** ../vim-7.4.083/src/if_py_both.h	2013-11-04 00:34:47.000000000 +0100
dcaee6
--- src/if_py_both.h	2013-11-11 00:56:41.000000000 +0100
dcaee6
***************
dcaee6
*** 558,564 ****
dcaee6
      /* Keyboard interrupt should be preferred over anything else */
dcaee6
      if (got_int)
dcaee6
      {
dcaee6
! 	did_throw = got_int = FALSE;
dcaee6
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
dcaee6
  	return -1;
dcaee6
      }
dcaee6
--- 558,568 ----
dcaee6
      /* Keyboard interrupt should be preferred over anything else */
dcaee6
      if (got_int)
dcaee6
      {
dcaee6
! 	if (current_exception != NULL)
dcaee6
! 	    discard_current_exception();
dcaee6
! 	else
dcaee6
! 	    need_rethrow = did_throw = FALSE;
dcaee6
! 	got_int = FALSE;
dcaee6
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
dcaee6
  	return -1;
dcaee6
      }
dcaee6
***************
dcaee6
*** 567,573 ****
dcaee6
      /* Python exception is preferred over vim one; unlikely to occur though */
dcaee6
      else if (PyErr_Occurred())
dcaee6
      {
dcaee6
! 	did_throw = FALSE;
dcaee6
  	return -1;
dcaee6
      }
dcaee6
      /* Finally transform VimL exception to python one */
dcaee6
--- 571,580 ----
dcaee6
      /* Python exception is preferred over vim one; unlikely to occur though */
dcaee6
      else if (PyErr_Occurred())
dcaee6
      {
dcaee6
! 	if (current_exception != NULL)
dcaee6
! 	    discard_current_exception();
dcaee6
! 	else
dcaee6
! 	    need_rethrow = did_throw = FALSE;
dcaee6
  	return -1;
dcaee6
      }
dcaee6
      /* Finally transform VimL exception to python one */
dcaee6
*** ../vim-7.4.083/src/testdir/test86.in	2013-11-04 00:34:47.000000000 +0100
dcaee6
--- src/testdir/test86.in	2013-11-11 00:56:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1281,1286 ****
dcaee6
--- 1281,1317 ----
dcaee6
  EOF
dcaee6
  :delfunction Exe
dcaee6
  :"
dcaee6
+ :" Regression: interrupting vim.command propagates to next vim.command
dcaee6
+ py << EOF
dcaee6
+ def test_keyboard_interrupt():
dcaee6
+     try:
dcaee6
+         vim.command('while 1 | endwhile')
dcaee6
+     except KeyboardInterrupt:
dcaee6
+         cb.append('Caught KeyboardInterrupt')
dcaee6
+     except Exception:
dcaee6
+         cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
dcaee6
+     else:
dcaee6
+         cb.append('!!!!!!!! No exception')
dcaee6
+     try:
dcaee6
+         vim.command('$ put =\'Running :put\'')
dcaee6
+     except KeyboardInterrupt:
dcaee6
+         cb.append('!!!!!!!! Caught KeyboardInterrupt')
dcaee6
+     except Exception:
dcaee6
+         cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
dcaee6
+     else:
dcaee6
+         cb.append('No exception')
dcaee6
+ EOF
dcaee6
+ :debuggreedy
dcaee6
+ :call inputsave()
dcaee6
+ :call feedkeys("s\ns\ns\ns\nq\n")
dcaee6
+ :redir => output
dcaee6
+ :debug silent! py test_keyboard_interrupt()
dcaee6
+ :redir END
dcaee6
+ :0 debuggreedy
dcaee6
+ :silent $put =output
dcaee6
+ :unlet output
dcaee6
+ :py del test_keyboard_interrupt
dcaee6
+ :"
dcaee6
  :" Cleanup
dcaee6
  py << EOF
dcaee6
  del cb
dcaee6
*** ../vim-7.4.083/src/testdir/test86.ok	2013-11-04 00:34:47.000000000 +0100
dcaee6
--- src/testdir/test86.ok	2013-11-11 00:56:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1198,1200 ****
dcaee6
--- 1198,1204 ----
dcaee6
  vim.eval("Exe('echoerr ''jkl''')"):error:('Vim(echoerr):jkl',)
dcaee6
  vim.eval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
dcaee6
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
dcaee6
+ Caught KeyboardInterrupt
dcaee6
+ Running :put
dcaee6
+ No exception
dcaee6
+ 
dcaee6
*** ../vim-7.4.083/src/testdir/test87.in	2013-11-04 00:34:47.000000000 +0100
dcaee6
--- src/testdir/test87.in	2013-11-11 00:56:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1232,1237 ****
dcaee6
--- 1232,1268 ----
dcaee6
  EOF
dcaee6
  :delfunction Exe
dcaee6
  :"
dcaee6
+ :" Regression: interrupting vim.command propagates to next vim.command
dcaee6
+ py3 << EOF
dcaee6
+ def test_keyboard_interrupt():
dcaee6
+     try:
dcaee6
+         vim.command('while 1 | endwhile')
dcaee6
+     except KeyboardInterrupt:
dcaee6
+         cb.append('Caught KeyboardInterrupt')
dcaee6
+     except Exception as e:
dcaee6
+         cb.append('!!!!!!!! Caught exception: ' + repr(e))
dcaee6
+     else:
dcaee6
+         cb.append('!!!!!!!! No exception')
dcaee6
+     try:
dcaee6
+         vim.command('$ put =\'Running :put\'')
dcaee6
+     except KeyboardInterrupt:
dcaee6
+         cb.append('!!!!!!!! Caught KeyboardInterrupt')
dcaee6
+     except Exception as e:
dcaee6
+         cb.append('!!!!!!!! Caught exception: ' + repr(e))
dcaee6
+     else:
dcaee6
+         cb.append('No exception')
dcaee6
+ EOF
dcaee6
+ :debuggreedy
dcaee6
+ :call inputsave()
dcaee6
+ :call feedkeys("s\ns\ns\ns\nq\n")
dcaee6
+ :redir => output
dcaee6
+ :debug silent! py3 test_keyboard_interrupt()
dcaee6
+ :redir END
dcaee6
+ :0 debuggreedy
dcaee6
+ :silent $put =output
dcaee6
+ :unlet output
dcaee6
+ :py3 del test_keyboard_interrupt
dcaee6
+ :"
dcaee6
  :" Cleanup
dcaee6
  py3 << EOF
dcaee6
  del cb
dcaee6
*** ../vim-7.4.083/src/testdir/test87.ok	2013-11-04 00:34:47.000000000 +0100
dcaee6
--- src/testdir/test87.ok	2013-11-11 00:56:11.000000000 +0100
dcaee6
***************
dcaee6
*** 1187,1189 ****
dcaee6
--- 1187,1193 ----
dcaee6
  vim.eval("Exe('echoerr ''jkl''')"):(<class 'vim.error'>, error('Vim(echoerr):jkl',))
dcaee6
  vim.eval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
dcaee6
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
dcaee6
+ Caught KeyboardInterrupt
dcaee6
+ Running :put
dcaee6
+ No exception
dcaee6
+ 
dcaee6
*** ../vim-7.4.083/src/version.c	2013-11-09 05:30:18.000000000 +0100
dcaee6
--- src/version.c	2013-11-11 00:55:23.000000000 +0100
dcaee6
***************
dcaee6
*** 740,741 ****
dcaee6
--- 740,743 ----
dcaee6
  {   /* Add new patch number below this line */
dcaee6
+ /**/
dcaee6
+     84,
dcaee6
  /**/
dcaee6
dcaee6
-- 
dcaee6
Computers make very fast, very accurate, mistakes.
dcaee6
dcaee6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dcaee6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dcaee6
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
dcaee6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///