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