[2.7] bpo-31285: Don't raise a SystemError in warnings.warn_explicit() in case __loader__.get_source() has a bad splitlines() method. (GH-3219) (#3823)
(cherry picked from commit 91fb0af)
diff --git a/Python/_warnings.c b/Python/_warnings.c
index dd168f9..37875e5 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -684,8 +684,9 @@
}
/* Split the source into lines. */
- source_list = PyObject_CallMethodObjArgs(source, splitlines_name,
- NULL);
+ source_list = PyObject_CallMethodObjArgs((PyObject *)&PyString_Type,
+ splitlines_name, source,
+ NULL);
Py_DECREF(source);
if (!source_list)
return NULL;