Karsten Hopp f3a23f
To: vim_dev@googlegroups.com
Karsten Hopp f3a23f
Subject: Patch 7.3.1046
Karsten Hopp f3a23f
Fcc: outbox
Karsten Hopp f3a23f
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f3a23f
Mime-Version: 1.0
Karsten Hopp f3a23f
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f3a23f
Content-Transfer-Encoding: 8bit
Karsten Hopp f3a23f
------------
Karsten Hopp f3a23f
Karsten Hopp f3a23f
Patch 7.3.1046
Karsten Hopp f3a23f
Problem:    Python: Using Py_BuildValue for building strings.
Karsten Hopp f3a23f
Solution:   Python patch 7 and 7.5: Replace Py_BuildValue with
Karsten Hopp f3a23f
	    PyString_FromString. (ZyX)
Karsten Hopp f3a23f
Files:	    src/if_py_both.h
Karsten Hopp f3a23f
Karsten Hopp f3a23f
Karsten Hopp f3a23f
*** ../vim-7.3.1045/src/if_py_both.h	2013-05-29 22:19:57.000000000 +0200
Karsten Hopp f3a23f
--- src/if_py_both.h	2013-05-29 22:24:52.000000000 +0200
Karsten Hopp f3a23f
***************
Karsten Hopp f3a23f
*** 442,448 ****
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
      if (our_tv->v_type == VAR_STRING)
Karsten Hopp f3a23f
      {
Karsten Hopp f3a23f
! 	result = Py_BuildValue("s", our_tv->vval.v_string == NULL
Karsten Hopp f3a23f
  					? "" : (char *)our_tv->vval.v_string);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_NUMBER)
Karsten Hopp f3a23f
--- 442,448 ----
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
      if (our_tv->v_type == VAR_STRING)
Karsten Hopp f3a23f
      {
Karsten Hopp f3a23f
! 	result = PyString_FromString(our_tv->vval.v_string == NULL
Karsten Hopp f3a23f
  					? "" : (char *)our_tv->vval.v_string);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_NUMBER)
Karsten Hopp f3a23f
***************
Karsten Hopp f3a23f
*** 451,457 ****
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
  	/* For backwards compatibility numbers are stored as strings. */
Karsten Hopp f3a23f
  	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
Karsten Hopp f3a23f
! 	result = Py_BuildValue("s", buf);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
  # ifdef FEAT_FLOAT
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_FLOAT)
Karsten Hopp f3a23f
--- 451,457 ----
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
  	/* For backwards compatibility numbers are stored as strings. */
Karsten Hopp f3a23f
  	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
Karsten Hopp f3a23f
! 	result = PyString_FromString((char *) buf);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
  # ifdef FEAT_FLOAT
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_FLOAT)
Karsten Hopp f3a23f
***************
Karsten Hopp f3a23f
*** 459,465 ****
Karsten Hopp f3a23f
  	char buf[NUMBUFLEN];
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
  	sprintf(buf, "%f", our_tv->vval.v_float);
Karsten Hopp f3a23f
! 	result = Py_BuildValue("s", buf);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
  # endif
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_LIST)
Karsten Hopp f3a23f
--- 459,465 ----
Karsten Hopp f3a23f
  	char buf[NUMBUFLEN];
Karsten Hopp f3a23f
  
Karsten Hopp f3a23f
  	sprintf(buf, "%f", our_tv->vval.v_float);
Karsten Hopp f3a23f
! 	result = PyString_FromString((char *) buf);
Karsten Hopp f3a23f
      }
Karsten Hopp f3a23f
  # endif
Karsten Hopp f3a23f
      else if (our_tv->v_type == VAR_LIST)
Karsten Hopp f3a23f
***************
Karsten Hopp f3a23f
*** 3256,3262 ****
Karsten Hopp f3a23f
  BufferAttr(BufferObject *self, char *name)
Karsten Hopp f3a23f
  {
Karsten Hopp f3a23f
      if (strcmp(name, "name") == 0)
Karsten Hopp f3a23f
! 	return Py_BuildValue("s", self->buf->b_ffname);
Karsten Hopp f3a23f
      else if (strcmp(name, "number") == 0)
Karsten Hopp f3a23f
  	return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum);
Karsten Hopp f3a23f
      else if (strcmp(name, "vars") == 0)
Karsten Hopp f3a23f
--- 3256,3263 ----
Karsten Hopp f3a23f
  BufferAttr(BufferObject *self, char *name)
Karsten Hopp f3a23f
  {
Karsten Hopp f3a23f
      if (strcmp(name, "name") == 0)
Karsten Hopp f3a23f
! 	return PyString_FromString((self->buf->b_ffname == NULL
Karsten Hopp f3a23f
! 				    ? "" : (char *) self->buf->b_ffname));
Karsten Hopp f3a23f
      else if (strcmp(name, "number") == 0)
Karsten Hopp f3a23f
  	return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum);
Karsten Hopp f3a23f
      else if (strcmp(name, "vars") == 0)
Karsten Hopp f3a23f
*** ../vim-7.3.1045/src/version.c	2013-05-29 22:19:57.000000000 +0200
Karsten Hopp f3a23f
--- src/version.c	2013-05-29 22:25:14.000000000 +0200
Karsten Hopp f3a23f
***************
Karsten Hopp f3a23f
*** 730,731 ****
Karsten Hopp f3a23f
--- 730,733 ----
Karsten Hopp f3a23f
  {   /* Add new patch number below this line */
Karsten Hopp f3a23f
+ /**/
Karsten Hopp f3a23f
+     1046,
Karsten Hopp f3a23f
  /**/
Karsten Hopp f3a23f
Karsten Hopp f3a23f
-- 
Karsten Hopp f3a23f
hundred-and-one symptoms of being an internet addict:
Karsten Hopp f3a23f
21. Your dog has its own home page.
Karsten Hopp f3a23f
Karsten Hopp f3a23f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f3a23f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f3a23f
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f3a23f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///