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