Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eaa2883

Browse files
committed
Issue #19512: builtin print() function uses an identifier instead of literal
string "flush" to call the flush method
1 parent e7f516c commit eaa2883

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/bltinmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
15471547
static PyObject *dummy_args;
15481548
PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL;
15491549
int i, err;
1550+
_Py_IDENTIFIER(flush);
15501551

15511552
if (dummy_args == NULL && !(dummy_args = PyTuple_New(0)))
15521553
return NULL;
@@ -1613,7 +1614,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
16131614
if (do_flush == -1)
16141615
return NULL;
16151616
else if (do_flush) {
1616-
tmp = PyObject_CallMethod(file, "flush", "");
1617+
tmp = _PyObject_CallMethodId(file, &PyId_flush, "");
16171618
if (tmp == NULL)
16181619
return NULL;
16191620
else

0 commit comments

Comments
 (0)