mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138205: Remove the resize method on mmap object on platforms don't support it (#138276)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
8554c0917e
commit
c919d02ede
5 changed files with 71 additions and 83 deletions
|
|
@ -628,6 +628,7 @@ is_writable(mmap_object *self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(HAVE_MREMAP)
|
||||
static int
|
||||
is_resizeable(mmap_object *self)
|
||||
{
|
||||
|
|
@ -648,6 +649,7 @@ is_resizeable(mmap_object *self)
|
|||
return 0;
|
||||
|
||||
}
|
||||
#endif /* MS_WINDOWS || HAVE_MREMAP */
|
||||
|
||||
|
||||
static PyObject *
|
||||
|
|
@ -766,6 +768,7 @@ mmap_size_method(PyObject *op, PyObject *Py_UNUSED(ignored))
|
|||
/ new size?
|
||||
*/
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(HAVE_MREMAP)
|
||||
static PyObject *
|
||||
mmap_resize_method(PyObject *op, PyObject *args)
|
||||
{
|
||||
|
|
@ -880,11 +883,6 @@ mmap_resize_method(PyObject *op, PyObject *args)
|
|||
#endif /* MS_WINDOWS */
|
||||
|
||||
#ifdef UNIX
|
||||
#ifndef HAVE_MREMAP
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"mmap: resizing not available--no mremap()");
|
||||
return NULL;
|
||||
#else
|
||||
void *newmap;
|
||||
|
||||
#ifdef __linux__
|
||||
|
|
@ -916,10 +914,10 @@ mmap_resize_method(PyObject *op, PyObject *args)
|
|||
self->data = newmap;
|
||||
self->size = new_size;
|
||||
Py_RETURN_NONE;
|
||||
#endif /* HAVE_MREMAP */
|
||||
#endif /* UNIX */
|
||||
}
|
||||
}
|
||||
#endif /* MS_WINDOWS || HAVE_MREMAP */
|
||||
|
||||
static PyObject *
|
||||
mmap_tell_method(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
|
|
@ -1207,7 +1205,9 @@ static struct PyMethodDef mmap_object_methods[] = {
|
|||
{"read", mmap_read_method, METH_VARARGS},
|
||||
{"read_byte", mmap_read_byte_method, METH_NOARGS},
|
||||
{"readline", mmap_read_line_method, METH_NOARGS},
|
||||
#if defined(MS_WINDOWS) || defined(HAVE_MREMAP)
|
||||
{"resize", mmap_resize_method, METH_VARARGS},
|
||||
#endif
|
||||
{"seek", mmap_seek_method, METH_VARARGS},
|
||||
{"seekable", mmap_seekable_method, METH_NOARGS},
|
||||
{"size", mmap_size_method, METH_NOARGS},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue