Skip to content

Commit e62a1c3

Browse files
committed
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)
1 parent 9bd6fbd commit e62a1c3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/if_py_both.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3549,13 +3549,26 @@ StringToLine(PyObject *obj)
35493549
if (!(bytes = PyUnicode_AsEncodedString(obj, ENC_OPT, NULL)))
35503550
return NULL;
35513551

3552-
if(PyBytes_AsStringAndSize(bytes, &str, &len) == -1
3552+
if (PyBytes_AsStringAndSize(bytes, &str, &len) == -1
35533553
|| str == NULL)
35543554
{
35553555
Py_DECREF(bytes);
35563556
return NULL;
35573557
}
35583558
}
3559+
else
3560+
{
3561+
#if PY_MAJOR_VERSION < 3
3562+
PyErr_FORMAT(PyExc_TypeError,
3563+
N_("expected str() or unicode() instance, but got %s"),
3564+
Py_TYPE_NAME(obj));
3565+
#else
3566+
PyErr_FORMAT(PyExc_TypeError,
3567+
N_("expected bytes() or str() instance, but got %s"),
3568+
Py_TYPE_NAME(obj));
3569+
#endif
3570+
return NULL;
3571+
}
35593572

35603573
/*
35613574
* Error checking: String must not contain newlines, as we

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ static char *(features[]) =
728728

729729
static int included_patches[] =
730730
{ /* Add new patch number below this line */
731+
/**/
732+
1242,
731733
/**/
732734
1241,
733735
/**/

0 commit comments

Comments
 (0)