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

Skip to content

Commit 74ba247

Browse files
committed
Reordered list of methods to hopefully put the most frequently used
ones near the front. Also added a missing "return -1" to PyFile_WriteString.
1 parent 4dddff8 commit 74ba247

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Objects/fileobject.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -839,21 +839,21 @@ file_writelines(f, args)
839839
}
840840

841841
static PyMethodDef file_methods[] = {
842-
{"close", (PyCFunction)file_close, 0},
843-
{"flush", (PyCFunction)file_flush, 0},
844-
{"fileno", (PyCFunction)file_fileno, 0},
845-
{"isatty", (PyCFunction)file_isatty, 0},
846-
{"read", (PyCFunction)file_read, 1},
847842
{"readline", (PyCFunction)file_readline, 1},
848-
{"readlines", (PyCFunction)file_readlines, 1},
843+
{"read", (PyCFunction)file_read, 1},
844+
{"write", (PyCFunction)file_write, 0},
845+
{"fileno", (PyCFunction)file_fileno, 0},
849846
{"seek", (PyCFunction)file_seek, 0},
850847
#ifdef HAVE_FTRUNCATE
851848
{"truncate", (PyCFunction)file_truncate, 0},
852849
#endif
853850
{"tell", (PyCFunction)file_tell, 0},
854-
{"write", (PyCFunction)file_write, 0},
855-
{"writelines", (PyCFunction)file_writelines, 0},
856851
{"readinto", (PyCFunction)file_readinto, 0},
852+
{"readlines", (PyCFunction)file_readlines, 1},
853+
{"writelines", (PyCFunction)file_writelines, 0},
854+
{"flush", (PyCFunction)file_flush, 0},
855+
{"close", (PyCFunction)file_close, 0},
856+
{"isatty", (PyCFunction)file_isatty, 0},
857857
{NULL, NULL} /* sentinel */
858858
};
859859

@@ -1027,4 +1027,6 @@ PyFile_WriteString(s, f)
10271027
Py_DECREF(v);
10281028
return err;
10291029
}
1030+
else
1031+
return -1;
10301032
}

0 commit comments

Comments
 (0)