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

Skip to content

Commit e2ec3eb

Browse files
author
Michael W. Hudson
committed
fix for
[ #476557 ] Wrong error message for file.write(a, b) Makes file.write a METH_VARARGS function.
1 parent 2dab9c7 commit e2ec3eb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Objects/fileobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ file_write(PyFileObject *f, PyObject *args)
11611161
int n, n2;
11621162
if (f->f_fp == NULL)
11631163
return err_closed();
1164-
if (!PyArg_Parse(args, f->f_binary ? "s#" : "t#", &s, &n))
1164+
if (!PyArg_ParseTuple(args, f->f_binary ? "s#" : "t#", &s, &n))
11651165
return NULL;
11661166
f->f_softspace = 0;
11671167
Py_BEGIN_ALLOW_THREADS
@@ -1378,7 +1378,7 @@ static char isatty_doc[] =
13781378
static PyMethodDef file_methods[] = {
13791379
{"readline", (PyCFunction)file_readline, METH_VARARGS, readline_doc},
13801380
{"read", (PyCFunction)file_read, METH_VARARGS, read_doc},
1381-
{"write", (PyCFunction)file_write, METH_OLDARGS, write_doc},
1381+
{"write", (PyCFunction)file_write, METH_VARARGS, write_doc},
13821382
{"fileno", (PyCFunction)file_fileno, METH_NOARGS, fileno_doc},
13831383
{"seek", (PyCFunction)file_seek, METH_VARARGS, seek_doc},
13841384
#ifdef HAVE_FTRUNCATE

0 commit comments

Comments
 (0)