Karsten Hopp 0b4355
To: vim_dev@googlegroups.com
Karsten Hopp 0b4355
Subject: Patch 7.3.1242
Karsten Hopp 0b4355
Fcc: outbox
Karsten Hopp 0b4355
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0b4355
Mime-Version: 1.0
Karsten Hopp 0b4355
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 0b4355
Content-Transfer-Encoding: 8bit
Karsten Hopp 0b4355
------------
Karsten Hopp 0b4355
Karsten Hopp 0b4355
Patch 7.3.1242
Karsten Hopp 0b4355
Problem:    No failure when trying to use a number as a string.
Karsten Hopp 0b4355
Solution:   Give an error when StringToLine() is called with an instance of
Karsten Hopp 0b4355
	    the wrong type. (Jun Takimoto)
Karsten Hopp 0b4355
Files:	    src/if_py_both.h
Karsten Hopp 0b4355
Karsten Hopp 0b4355
Karsten Hopp 0b4355
*** ../vim-7.3.1241/src/if_py_both.h	2013-06-24 21:21:52.000000000 +0200
Karsten Hopp 0b4355
--- src/if_py_both.h	2013-06-24 22:30:51.000000000 +0200
Karsten Hopp 0b4355
***************
Karsten Hopp 0b4355
*** 3549,3561 ****
Karsten Hopp 0b4355
  	if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
Karsten Hopp 0b4355
  	    return NULL;
Karsten Hopp 0b4355
  
Karsten Hopp 0b4355
! 	if(PyBytes_AsStringAndSize(bytes, &str, &len) == -1
Karsten Hopp 0b4355
  		|| str == NULL)
Karsten Hopp 0b4355
  	{
Karsten Hopp 0b4355
  	    Py_DECREF(bytes);
Karsten Hopp 0b4355
  	    return NULL;
Karsten Hopp 0b4355
  	}
Karsten Hopp 0b4355
      }
Karsten Hopp 0b4355
  
Karsten Hopp 0b4355
      /*
Karsten Hopp 0b4355
       * Error checking: String must not contain newlines, as we
Karsten Hopp 0b4355
--- 3549,3574 ----
Karsten Hopp 0b4355
  	if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
Karsten Hopp 0b4355
  	    return NULL;
Karsten Hopp 0b4355
  
Karsten Hopp 0b4355
! 	if (PyBytes_AsStringAndSize(bytes, &str, &len) == -1
Karsten Hopp 0b4355
  		|| str == NULL)
Karsten Hopp 0b4355
  	{
Karsten Hopp 0b4355
  	    Py_DECREF(bytes);
Karsten Hopp 0b4355
  	    return NULL;
Karsten Hopp 0b4355
  	}
Karsten Hopp 0b4355
      }
Karsten Hopp 0b4355
+     else
Karsten Hopp 0b4355
+     {
Karsten Hopp 0b4355
+ #if PY_MAJOR_VERSION < 3
Karsten Hopp 0b4355
+ 	PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp 0b4355
+ 		N_("expected str() or unicode() instance, but got %s"),
Karsten Hopp 0b4355
+ 		Py_TYPE_NAME(obj));
Karsten Hopp 0b4355
+ #else
Karsten Hopp 0b4355
+ 	PyErr_FORMAT(PyExc_TypeError,
Karsten Hopp 0b4355
+ 		N_("expected bytes() or str() instance, but got %s"),
Karsten Hopp 0b4355
+ 		Py_TYPE_NAME(obj));
Karsten Hopp 0b4355
+ #endif
Karsten Hopp 0b4355
+ 	return NULL;
Karsten Hopp 0b4355
+     }
Karsten Hopp 0b4355
  
Karsten Hopp 0b4355
      /*
Karsten Hopp 0b4355
       * Error checking: String must not contain newlines, as we
Karsten Hopp 0b4355
*** ../vim-7.3.1241/src/version.c	2013-06-24 22:23:51.000000000 +0200
Karsten Hopp 0b4355
--- src/version.c	2013-06-24 22:32:19.000000000 +0200
Karsten Hopp 0b4355
***************
Karsten Hopp 0b4355
*** 730,731 ****
Karsten Hopp 0b4355
--- 730,733 ----
Karsten Hopp 0b4355
  {   /* Add new patch number below this line */
Karsten Hopp 0b4355
+ /**/
Karsten Hopp 0b4355
+     1242,
Karsten Hopp 0b4355
  /**/
Karsten Hopp 0b4355
Karsten Hopp 0b4355
-- 
Karsten Hopp 0b4355
A successful man is one who makes more money than his wife can spend.
Karsten Hopp 0b4355
A successful woman is one who can find such a man.
Karsten Hopp 0b4355
Karsten Hopp 0b4355
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0b4355
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0b4355
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 0b4355
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///