summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-08-19 14:11:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-08-19 14:11:20 (GMT)
commit76b47655ffcb012dda7886dbdbf80c36254c5d2c (patch)
tree68782d33168d551098be21ce7fabfa1496ae756c /Modules
parentd6ec309c368d300913f776b8d19e35224c7a44b7 (diff)
downloadcpython-76b47655ffcb012dda7886dbdbf80c36254c5d2c.zip
cpython-76b47655ffcb012dda7886dbdbf80c36254c5d2c.tar.gz
cpython-76b47655ffcb012dda7886dbdbf80c36254c5d2c.tar.bz2
Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 07b5c6b..1371424 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -709,6 +709,19 @@ mmap__exit__method(PyObject *self, PyObject *args)
return _PyObject_CallMethodId(self, &PyId_close, NULL);
}
+#ifdef MS_WINDOWS
+static PyObject *
+mmap__sizeof__method(mmap_object *self, void *unused)
+{
+ Py_ssize_t res;
+
+ res = sizeof(mmap_object);
+ if (self->tagname)
+ res += strlen(self->tagname) + 1;
+ return PyLong_FromSsize_t(res);
+}
+#endif
+
static struct PyMethodDef mmap_object_methods[] = {
{"close", (PyCFunction) mmap_close_method, METH_NOARGS},
{"find", (PyCFunction) mmap_find_method, METH_VARARGS},
@@ -726,6 +739,9 @@ static struct PyMethodDef mmap_object_methods[] = {
{"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS},
{"__enter__", (PyCFunction) mmap__enter__method, METH_NOARGS},
{"__exit__", (PyCFunction) mmap__exit__method, METH_VARARGS},
+#ifdef MS_WINDOWS
+ {"__sizeof__", (PyCFunction) mmap__sizeof__method, METH_NOARGS},
+#endif
{NULL, NULL} /* sentinel */
};