Karsten Hopp 438ef4
To: vim_dev@googlegroups.com
Karsten Hopp 438ef4
Subject: Patch 7.3.1096
Karsten Hopp 438ef4
Fcc: outbox
Karsten Hopp 438ef4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 438ef4
Mime-Version: 1.0
Karsten Hopp 438ef4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 438ef4
Content-Transfer-Encoding: 8bit
Karsten Hopp 438ef4
------------
Karsten Hopp 438ef4
Karsten Hopp 438ef4
Patch 7.3.1096
Karsten Hopp 438ef4
Problem:    Python: popitem() was not defined in a standard way.
Karsten Hopp 438ef4
Solution:   Remove the argument from popitem(). (ZyX)
Karsten Hopp 438ef4
Files:	    runtime/doc/if_pyth.txt, src/if_py_both.h, src/testdir/test86.in,
Karsten Hopp 438ef4
	    src/testdir/test86.ok, src/testdir/test87.in,
Karsten Hopp 438ef4
	    src/testdir/test87.ok
Karsten Hopp 438ef4
Karsten Hopp 438ef4
Karsten Hopp 438ef4
*** ../vim-7.3.1095/runtime/doc/if_pyth.txt	2013-05-30 13:32:26.000000000 +0200
Karsten Hopp 438ef4
--- runtime/doc/if_pyth.txt	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 174,180 ****
Karsten Hopp 438ef4
  vim.bindeval(str)					*python-bindeval*
Karsten Hopp 438ef4
  	Like |python-eval|, but returns special objects described in 
Karsten Hopp 438ef4
  	|python-bindeval-objects|. These python objects let you modify (|List| 
Karsten Hopp 438ef4
! 	or |Dictionary|) or call (|Funcref|) vim objecs.
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  Error object of the "vim" module
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
--- 174,180 ----
Karsten Hopp 438ef4
  vim.bindeval(str)					*python-bindeval*
Karsten Hopp 438ef4
  	Like |python-eval|, but returns special objects described in 
Karsten Hopp 438ef4
  	|python-bindeval-objects|. These python objects let you modify (|List| 
Karsten Hopp 438ef4
! 	or |Dictionary|) or call (|Funcref|) vim objects.
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  Error object of the "vim" module
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 208,214 ****
Karsten Hopp 438ef4
  	    :py w in vim.windows	# Membership test
Karsten Hopp 438ef4
  	    :py n = len(vim.windows)	# Number of elements
Karsten Hopp 438ef4
  	    :py for w in vim.windows:	# Sequential access
Karsten Hopp 438ef4
! <	Note: vim.windows object always accesses current tab page,. 
Karsten Hopp 438ef4
  	|python-tabpage|.windows objects are bound to parent |python-tabpage| 
Karsten Hopp 438ef4
  	object and always use windows from that tab page (or throw vim.error 
Karsten Hopp 438ef4
  	in case tab page was deleted). You can keep a reference to both 
Karsten Hopp 438ef4
--- 208,214 ----
Karsten Hopp 438ef4
  	    :py w in vim.windows	# Membership test
Karsten Hopp 438ef4
  	    :py n = len(vim.windows)	# Number of elements
Karsten Hopp 438ef4
  	    :py for w in vim.windows:	# Sequential access
Karsten Hopp 438ef4
! <	Note: vim.windows object always accesses current tab page. 
Karsten Hopp 438ef4
  	|python-tabpage|.windows objects are bound to parent |python-tabpage| 
Karsten Hopp 438ef4
  	object and always use windows from that tab page (or throw vim.error 
Karsten Hopp 438ef4
  	in case tab page was deleted). You can keep a reference to both 
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 494,503 ****
Karsten Hopp 438ef4
                      Remove specified key from dictionary and return 
Karsten Hopp 438ef4
                      corresponding value. If key is not found and default is 
Karsten Hopp 438ef4
                      given returns the default, otherwise raises KeyError.
Karsten Hopp 438ef4
!         popitem(key)
Karsten Hopp 438ef4
!                     Remove specified key from dictionary and return a pair 
Karsten Hopp 438ef4
!                     with it and the corresponding value. Returned key is a new 
Karsten Hopp 438ef4
!                     object.
Karsten Hopp 438ef4
          has_key(key)
Karsten Hopp 438ef4
                      Check whether dictionary contains specified key, similar 
Karsten Hopp 438ef4
                      to `key in dict`.
Karsten Hopp 438ef4
--- 494,502 ----
Karsten Hopp 438ef4
                      Remove specified key from dictionary and return 
Karsten Hopp 438ef4
                      corresponding value. If key is not found and default is 
Karsten Hopp 438ef4
                      given returns the default, otherwise raises KeyError.
Karsten Hopp 438ef4
!         popitem()
Karsten Hopp 438ef4
!                     Remove random key from dictionary and return (key, value) 
Karsten Hopp 438ef4
!                     pair.
Karsten Hopp 438ef4
          has_key(key)
Karsten Hopp 438ef4
                      Check whether dictionary contains specified key, similar 
Karsten Hopp 438ef4
                      to `key in dict`.
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/if_py_both.h	2013-05-31 20:49:27.000000000 +0200
Karsten Hopp 438ef4
--- src/if_py_both.h	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 1061,1077 ****
Karsten Hopp 438ef4
  	dictitem_free(di);
Karsten Hopp 438ef4
      }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
-     if (flags & DICT_FLAG_RETURN_PAIR)
Karsten Hopp 438ef4
-     {
Karsten Hopp 438ef4
- 	PyObject	*tmp = r;
Karsten Hopp 438ef4
- 
Karsten Hopp 438ef4
- 	if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, tmp)))
Karsten Hopp 438ef4
- 	{
Karsten Hopp 438ef4
- 	    Py_DECREF(tmp);
Karsten Hopp 438ef4
- 	    return NULL;
Karsten Hopp 438ef4
- 	}
Karsten Hopp 438ef4
-     }
Karsten Hopp 438ef4
- 
Karsten Hopp 438ef4
      return r;
Karsten Hopp 438ef4
  }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
--- 1061,1066 ----
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 1457,1471 ****
Karsten Hopp 438ef4
  }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
      static PyObject *
Karsten Hopp 438ef4
! DictionaryPopItem(DictionaryObject *self, PyObject *args)
Karsten Hopp 438ef4
  {
Karsten Hopp 438ef4
!     PyObject	*keyObject;
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
!     if (!PyArg_ParseTuple(args, "O", &keyObject))
Karsten Hopp 438ef4
  	return NULL;
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
!     return _DictionaryItem(self, keyObject,
Karsten Hopp 438ef4
! 			    DICT_FLAG_POP|DICT_FLAG_RETURN_PAIR);
Karsten Hopp 438ef4
  }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
      static PyObject *
Karsten Hopp 438ef4
--- 1446,1483 ----
Karsten Hopp 438ef4
  }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
      static PyObject *
Karsten Hopp 438ef4
! DictionaryPopItem(DictionaryObject *self)
Karsten Hopp 438ef4
  {
Karsten Hopp 438ef4
!     hashitem_T	*hi;
Karsten Hopp 438ef4
!     PyObject	*r;
Karsten Hopp 438ef4
!     PyObject	*valObject;
Karsten Hopp 438ef4
!     dictitem_T	*di;
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
!     if (self->dict->dv_hashtab.ht_used == 0)
Karsten Hopp 438ef4
!     {
Karsten Hopp 438ef4
! 	PyErr_SetNone(PyExc_KeyError);
Karsten Hopp 438ef4
! 	return NULL;
Karsten Hopp 438ef4
!     }
Karsten Hopp 438ef4
! 
Karsten Hopp 438ef4
!     hi = self->dict->dv_hashtab.ht_array;
Karsten Hopp 438ef4
!     while (HASHITEM_EMPTY(hi))
Karsten Hopp 438ef4
! 	++hi;
Karsten Hopp 438ef4
! 
Karsten Hopp 438ef4
!     di = dict_lookup(hi);
Karsten Hopp 438ef4
! 
Karsten Hopp 438ef4
!     if (!(valObject = ConvertToPyObject(&di->di_tv)))
Karsten Hopp 438ef4
  	return NULL;
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
!     if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, valObject)))
Karsten Hopp 438ef4
!     {
Karsten Hopp 438ef4
! 	Py_DECREF(valObject);
Karsten Hopp 438ef4
! 	return NULL;
Karsten Hopp 438ef4
!     }
Karsten Hopp 438ef4
! 
Karsten Hopp 438ef4
!     hash_remove(&self->dict->dv_hashtab, hi);
Karsten Hopp 438ef4
!     dictitem_free(di);
Karsten Hopp 438ef4
! 
Karsten Hopp 438ef4
!     return r;
Karsten Hopp 438ef4
  }
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
      static PyObject *
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 1505,1511 ****
Karsten Hopp 438ef4
      {"update",	(PyCFunction)DictionaryUpdate,		METH_VARARGS|METH_KEYWORDS, ""},
Karsten Hopp 438ef4
      {"get",	(PyCFunction)DictionaryGet,		METH_VARARGS,	""},
Karsten Hopp 438ef4
      {"pop",	(PyCFunction)DictionaryPop,		METH_VARARGS,	""},
Karsten Hopp 438ef4
!     {"popitem",	(PyCFunction)DictionaryPopItem,		METH_VARARGS,	""},
Karsten Hopp 438ef4
      {"has_key",	(PyCFunction)DictionaryHasKey,		METH_VARARGS,	""},
Karsten Hopp 438ef4
      {"__dir__",	(PyCFunction)DictionaryDir,		METH_NOARGS,	""},
Karsten Hopp 438ef4
      { NULL,	NULL,					0,		NULL}
Karsten Hopp 438ef4
--- 1517,1523 ----
Karsten Hopp 438ef4
      {"update",	(PyCFunction)DictionaryUpdate,		METH_VARARGS|METH_KEYWORDS, ""},
Karsten Hopp 438ef4
      {"get",	(PyCFunction)DictionaryGet,		METH_VARARGS,	""},
Karsten Hopp 438ef4
      {"pop",	(PyCFunction)DictionaryPop,		METH_VARARGS,	""},
Karsten Hopp 438ef4
!     {"popitem",	(PyCFunction)DictionaryPopItem,		METH_NOARGS,	""},
Karsten Hopp 438ef4
      {"has_key",	(PyCFunction)DictionaryHasKey,		METH_VARARGS,	""},
Karsten Hopp 438ef4
      {"__dir__",	(PyCFunction)DictionaryDir,		METH_NOARGS,	""},
Karsten Hopp 438ef4
      { NULL,	NULL,					0,		NULL}
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/testdir/test86.in	2013-06-01 20:32:09.000000000 +0200
Karsten Hopp 438ef4
--- src/testdir/test86.in	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 83,89 ****
Karsten Hopp 438ef4
  :$put =pyeval('repr(''1'' in d)')
Karsten Hopp 438ef4
  :$put =pyeval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :$put =string(d)
Karsten Hopp 438ef4
! :$put =pyeval('repr(d.popitem(''0''))')
Karsten Hopp 438ef4
  :$put =pyeval('repr(d.get(''0''))')
Karsten Hopp 438ef4
  :$put =pyeval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :"
Karsten Hopp 438ef4
--- 83,89 ----
Karsten Hopp 438ef4
  :$put =pyeval('repr(''1'' in d)')
Karsten Hopp 438ef4
  :$put =pyeval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :$put =string(d)
Karsten Hopp 438ef4
! :$put =pyeval('repr(d.popitem())')
Karsten Hopp 438ef4
  :$put =pyeval('repr(d.get(''0''))')
Karsten Hopp 438ef4
  :$put =pyeval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :"
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 226,232 ****
Karsten Hopp 438ef4
  em('d[u"a\\0b"]=1')
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  em('d.pop("abc")')
Karsten Hopp 438ef4
! em('d.popitem("abc")')
Karsten Hopp 438ef4
  EOF
Karsten Hopp 438ef4
  :$put =messages
Karsten Hopp 438ef4
  :unlet messages
Karsten Hopp 438ef4
--- 226,232 ----
Karsten Hopp 438ef4
  em('d[u"a\\0b"]=1')
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  em('d.pop("abc")')
Karsten Hopp 438ef4
! em('d.popitem()')
Karsten Hopp 438ef4
  EOF
Karsten Hopp 438ef4
  :$put =messages
Karsten Hopp 438ef4
  :unlet messages
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/testdir/test86.ok	2013-06-01 20:32:09.000000000 +0200
Karsten Hopp 438ef4
--- src/testdir/test86.ok	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 26,32 ****
Karsten Hopp 438ef4
  False
Karsten Hopp 438ef4
  ['0']
Karsten Hopp 438ef4
  {'0': -1}
Karsten Hopp 438ef4
! ('', -1L)
Karsten Hopp 438ef4
  None
Karsten Hopp 438ef4
  []
Karsten Hopp 438ef4
  [0, 1, 2, 3]
Karsten Hopp 438ef4
--- 26,32 ----
Karsten Hopp 438ef4
  False
Karsten Hopp 438ef4
  ['0']
Karsten Hopp 438ef4
  {'0': -1}
Karsten Hopp 438ef4
! ('0', -1L)
Karsten Hopp 438ef4
  None
Karsten Hopp 438ef4
  []
Karsten Hopp 438ef4
  [0, 1, 2, 3]
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 666,672 ****
Karsten Hopp 438ef4
  d.update((("a", FailingMappingKey()),)):(<type 'exceptions.NotImplementedError'>, NotImplementedError())
Karsten Hopp 438ef4
  <<< Finished
Karsten Hopp 438ef4
  >> DictionaryPopItem
Karsten Hopp 438ef4
! d.popitem(1, 2):(<type 'exceptions.TypeError'>, TypeError('function takes exactly 1 argument (2 given)',))
Karsten Hopp 438ef4
  >> DictionaryHasKey
Karsten Hopp 438ef4
  d.has_key():(<type 'exceptions.TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
Karsten Hopp 438ef4
  > List
Karsten Hopp 438ef4
--- 666,672 ----
Karsten Hopp 438ef4
  d.update((("a", FailingMappingKey()),)):(<type 'exceptions.NotImplementedError'>, NotImplementedError())
Karsten Hopp 438ef4
  <<< Finished
Karsten Hopp 438ef4
  >> DictionaryPopItem
Karsten Hopp 438ef4
! d.popitem(1, 2):(<type 'exceptions.TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
Karsten Hopp 438ef4
  >> DictionaryHasKey
Karsten Hopp 438ef4
  d.has_key():(<type 'exceptions.TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
Karsten Hopp 438ef4
  > List
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/testdir/test87.in	2013-06-01 20:32:09.000000000 +0200
Karsten Hopp 438ef4
--- src/testdir/test87.in	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 77,83 ****
Karsten Hopp 438ef4
  :$put =py3eval('repr(''1'' in d)')
Karsten Hopp 438ef4
  :$put =py3eval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :$put =string(d)
Karsten Hopp 438ef4
! :$put =py3eval('repr(d.popitem(''0''))')
Karsten Hopp 438ef4
  :$put =py3eval('repr(d.get(''0''))')
Karsten Hopp 438ef4
  :$put =py3eval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :"
Karsten Hopp 438ef4
--- 77,83 ----
Karsten Hopp 438ef4
  :$put =py3eval('repr(''1'' in d)')
Karsten Hopp 438ef4
  :$put =py3eval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :$put =string(d)
Karsten Hopp 438ef4
! :$put =py3eval('repr(d.popitem())')
Karsten Hopp 438ef4
  :$put =py3eval('repr(d.get(''0''))')
Karsten Hopp 438ef4
  :$put =py3eval('repr(list(iter(d)))')
Karsten Hopp 438ef4
  :"
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 220,226 ****
Karsten Hopp 438ef4
  em('d[b"a\\0b"]=1')
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  em('d.pop("abc")')
Karsten Hopp 438ef4
! em('d.popitem("abc")')
Karsten Hopp 438ef4
  EOF
Karsten Hopp 438ef4
  :$put =messages
Karsten Hopp 438ef4
  :unlet messages
Karsten Hopp 438ef4
--- 220,226 ----
Karsten Hopp 438ef4
  em('d[b"a\\0b"]=1')
Karsten Hopp 438ef4
  
Karsten Hopp 438ef4
  em('d.pop("abc")')
Karsten Hopp 438ef4
! em('d.popitem()')
Karsten Hopp 438ef4
  EOF
Karsten Hopp 438ef4
  :$put =messages
Karsten Hopp 438ef4
  :unlet messages
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/testdir/test87.ok	2013-06-01 20:32:09.000000000 +0200
Karsten Hopp 438ef4
--- src/testdir/test87.ok	2013-06-02 17:39:35.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 26,32 ****
Karsten Hopp 438ef4
  False
Karsten Hopp 438ef4
  [b'0']
Karsten Hopp 438ef4
  {'0': -1}
Karsten Hopp 438ef4
! (b'', -1)
Karsten Hopp 438ef4
  None
Karsten Hopp 438ef4
  []
Karsten Hopp 438ef4
  [0, 1, 2, 3]
Karsten Hopp 438ef4
--- 26,32 ----
Karsten Hopp 438ef4
  False
Karsten Hopp 438ef4
  [b'0']
Karsten Hopp 438ef4
  {'0': -1}
Karsten Hopp 438ef4
! (b'0', -1)
Karsten Hopp 438ef4
  None
Karsten Hopp 438ef4
  []
Karsten Hopp 438ef4
  [0, 1, 2, 3]
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 663,669 ****
Karsten Hopp 438ef4
  d.update((("a", FailingMappingKey()),)):(<class 'NotImplementedError'>, NotImplementedError())
Karsten Hopp 438ef4
  <<< Finished
Karsten Hopp 438ef4
  >> DictionaryPopItem
Karsten Hopp 438ef4
! d.popitem(1, 2):(<class 'TypeError'>, TypeError('function takes exactly 1 argument (2 given)',))
Karsten Hopp 438ef4
  >> DictionaryHasKey
Karsten Hopp 438ef4
  d.has_key():(<class 'TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
Karsten Hopp 438ef4
  > List
Karsten Hopp 438ef4
--- 663,669 ----
Karsten Hopp 438ef4
  d.update((("a", FailingMappingKey()),)):(<class 'NotImplementedError'>, NotImplementedError())
Karsten Hopp 438ef4
  <<< Finished
Karsten Hopp 438ef4
  >> DictionaryPopItem
Karsten Hopp 438ef4
! d.popitem(1, 2):(<class 'TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
Karsten Hopp 438ef4
  >> DictionaryHasKey
Karsten Hopp 438ef4
  d.has_key():(<class 'TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
Karsten Hopp 438ef4
  > List
Karsten Hopp 438ef4
*** ../vim-7.3.1095/src/version.c	2013-06-02 16:40:44.000000000 +0200
Karsten Hopp 438ef4
--- src/version.c	2013-06-02 17:40:20.000000000 +0200
Karsten Hopp 438ef4
***************
Karsten Hopp 438ef4
*** 730,731 ****
Karsten Hopp 438ef4
--- 730,733 ----
Karsten Hopp 438ef4
  {   /* Add new patch number below this line */
Karsten Hopp 438ef4
+ /**/
Karsten Hopp 438ef4
+     1096,
Karsten Hopp 438ef4
  /**/
Karsten Hopp 438ef4
Karsten Hopp 438ef4
-- 
Karsten Hopp 438ef4
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 438ef4
44. Your friends no longer send you e-mail...they just log on to your IRC
Karsten Hopp 438ef4
    channel.
Karsten Hopp 438ef4
Karsten Hopp 438ef4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 438ef4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 438ef4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 438ef4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///