Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.4.176
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.176
Problem:    Dictionary.update() thows an error when used without arguments.
	    Python programmers don't expect that.
Solution:   Make Dictionary.update() without arguments do nothing. (ZyX)
Files:	    src/if_py_both.h, src/testdir/test86.in, src/testdir/test87.in


*** ../vim-7.4.175/src/if_py_both.h	2014-02-11 16:00:31.198157698 +0100
--- src/if_py_both.h	2014-02-11 18:41:12.774305435 +0100
***************
*** 1918,1928 ****
      }
      else
      {
! 	PyObject	*obj;
  
! 	if (!PyArg_ParseTuple(args, "O", &obj))
  	    return NULL;
  
  	if (PyObject_HasAttrString(obj, "keys"))
  	    return DictionaryUpdate(self, NULL, obj);
  	else
--- 1919,1935 ----
      }
      else
      {
! 	PyObject	*obj = NULL;
  
! 	if (!PyArg_ParseTuple(args, "|O", &obj))
  	    return NULL;
  
+ 	if (obj == NULL)
+ 	{
+ 	    Py_INCREF(Py_None);
+ 	    return Py_None;
+ 	}
+ 
  	if (PyObject_HasAttrString(obj, "keys"))
  	    return DictionaryUpdate(self, NULL, obj);
  	else
*** ../vim-7.4.175/src/testdir/test86.in	2014-01-14 16:54:53.000000000 +0100
--- src/testdir/test86.in	2014-02-11 17:25:08.414235496 +0100
***************
*** 39,44 ****
--- 39,45 ----
  py << EOF
  d=vim.bindeval('d')
  d['1']='asd'
+ d.update()  # Must not do anything, including throwing errors
  d.update(b=[1, 2, f])
  d.update((('-1', {'a': 1}),))
  d.update({'0': -1})
*** ../vim-7.4.175/src/testdir/test87.in	2014-01-14 16:54:53.000000000 +0100
--- src/testdir/test87.in	2014-02-11 17:25:12.602235560 +0100
***************
*** 33,38 ****
--- 33,39 ----
  py3 << EOF
  d=vim.bindeval('d')
  d['1']='asd'
+ d.update()  # Must not do anything, including throwing errors
  d.update(b=[1, 2, f])
  d.update((('-1', {'a': 1}),))
  d.update({'0': -1})
*** ../vim-7.4.175/src/version.c	2014-02-11 17:05:57.282217857 +0100
--- src/version.c	2014-02-11 18:46:37.518310411 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     176,
  /**/

-- 
"Intelligence has much less practical application than you'd think."
		  -- Scott Adams, Dilbert.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///