Skip to content

pythongh-111835: Add seekable method to mmap.mmap #111865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The :class:`mmap.mmap` class now has an :meth:`~mmap.mmap.seekable` method that can be used where a file-like object with a seekable method is required. (Contributed by Sylvie Liberman in :gh:`111865`.)
9 changes: 9 additions & 0 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,14 @@ mmap_seek_method(mmap_object *self, PyObject *args)
return NULL;
}


static PyObject *
mmap_seekable_method(mmap_object *self, PyObject *unused)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mmap_seekable_method(mmap_object *self, PyObject *unused)
mmap_seekable_method(mmap_object *self, PyObject *Py_UNUSED(ignored))

{
Py_RETURN_TRUE;
}


static PyObject *
mmap_move_method(mmap_object *self, PyObject *args)
{
Expand Down Expand Up @@ -905,6 +913,7 @@ static struct PyMethodDef mmap_object_methods[] = {
{"readline", (PyCFunction) mmap_read_line_method, METH_NOARGS},
{"resize", (PyCFunction) mmap_resize_method, METH_VARARGS},
{"seek", (PyCFunction) mmap_seek_method, METH_VARARGS},
{"seekable", (PyCFunction) mmap_seekable_method, METH_NOARGS},
{"size", (PyCFunction) mmap_size_method, METH_NOARGS},
{"tell", (PyCFunction) mmap_tell_method, METH_NOARGS},
{"write", (PyCFunction) mmap_write_method, METH_VARARGS},
Expand Down