0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.1242

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)
This commit is contained in:
Bram Moolenaar
2013-06-24 22:33:30 +02:00
parent c8c13a0307
commit daa270289b
2 changed files with 16 additions and 1 deletions

View File

@@ -3549,13 +3549,26 @@ StringToLine(PyObject *obj)
if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL))) if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
return NULL; return NULL;
if(PyBytes_AsStringAndSize(bytes, &str, &len) == -1 if (PyBytes_AsStringAndSize(bytes, &str, &len) == -1
|| str == NULL) || str == NULL)
{ {
Py_DECREF(bytes); Py_DECREF(bytes);
return NULL; 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 * Error checking: String must not contain newlines, as we

View File

@@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1242,
/**/ /**/
1241, 1241,
/**/ /**/