updated for version 7.3.1242 v7.3.1242
authorBram Moolenaar <Bram@vim.org>
Mon, 24 Jun 2013 20:33:30 +0000 (22:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 Jun 2013 20:33:30 +0000 (22:33 +0200)
Problem:    No failure when trying to use a number as a string.
Solution:   Give an error when StringToLine() is called with an instance of
            the wrong type. (Jun Takimoto)

src/if_py_both.h
src/version.c

index d66e2cbd191e381ef9753360c1d98f5f18564604..b564d24b5d623220865b740ac0b28d610f461389 100644 (file)
@@ -3549,13 +3549,26 @@ StringToLine(PyObject *obj)
        if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
            return NULL;
 
-       if(PyBytes_AsStringAndSize(bytes, &str, &len) == -1
+       if (PyBytes_AsStringAndSize(bytes, &str, &len) == -1
                || str == NULL)
        {
            Py_DECREF(bytes);
            return NULL;
        }
     }
+    else
+    {
+#if PY_MAJOR_VERSION < 3
+       PyErr_FORMAT(PyExc_TypeError,
+               N_("expected str() or unicode() instance, but got %s"),
+               Py_TYPE_NAME(obj));
+#else
+       PyErr_FORMAT(PyExc_TypeError,
+               N_("expected bytes() or str() instance, but got %s"),
+               Py_TYPE_NAME(obj));
+#endif
+       return NULL;
+    }
 
     /*
      * Error checking: String must not contain newlines, as we
index 41e9e4d23dd1b54f8a70871bdb351ee9807e79af..cd804017c6508a895a7936ace213a85dd9b9a8bb 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1242,
 /**/
     1241,
 /**/