| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d6ec309 commit 76b4765
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | from test.support import (TESTFN, run_unittest, import_module, unlink, | |
| 2 | - requires, _2G, _4G, gc_collect) | ||
| 2 | + requires, _2G, _4G, gc_collect, cpython_only) | ||
| 3 | 3 | import unittest | |
| 4 | 4 | import os | |
| 5 | 5 | import re | |
@@ -639,6 +639,15 @@ def test_tagname(self): | |||
| 639 | 639 | m2.close() | |
| 640 | 640 | m1.close() | |
| 641 | 641 | ||
| 642 | + @cpython_only | ||
| 643 | + @unittest.skipUnless(os.name == 'nt', 'requires Windows') | ||
| 644 | + def test_sizeof(self): | ||
| 645 | + m1 = mmap.mmap(-1, 100) | ||
| 646 | + tagname = "foo" | ||
| 647 | + m2 = mmap.mmap(-1, 100, tagname=tagname) | ||
| 648 | + self.assertEqual(sys.getsize(m2), | ||
| 649 | + sys.getsize(m1) + len(tagname) + 1) | ||
| 650 | + | ||
| 642 | 651 | @unittest.skipUnless(os.name == 'nt', 'requires Windows') | |
| 643 | 652 | def test_crasher_on_windows(self): | |
| 644 | 653 | # Should not crash (Issue 1733986) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,8 @@ Core and Builtins | |||
| 27 | 27 | Library | |
| 28 | 28 | ------- | |
| 29 | 29 | ||
| 30 | + - Issue #15696: Add a __sizeof__ implementation for mmap objects on Windows. | ||
| 31 | + | ||
| 30 | 32 | - Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter. | |
| 31 | 33 | ||
| 32 | 34 | - Issue #22165: SimpleHTTPRequestHandler now supports undecodable file names. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -709,6 +709,19 @@ mmap__exit__method(PyObject *self, PyObject *args) | |||
| 709 | 709 | return _PyObject_CallMethodId(self, &PyId_close, NULL); | |
| 710 | 710 | } | |
| 711 | 711 | ||
| 712 | + #ifdef MS_WINDOWS | ||
| 713 | + static PyObject * | ||
| 714 | + mmap__sizeof__method(mmap_object *self, void *unused) | ||
| 715 | + { | ||
| 716 | + Py_ssize_t res; | ||
| 717 | + | ||
| 718 | + res = sizeof(mmap_object); | ||
| 719 | + if (self->tagname) | ||
| 720 | + res += strlen(self->tagname) + 1; | ||
| 721 | + return PyLong_FromSsize_t(res); | ||
| 722 | + } | ||
| 723 | + #endif | ||
| 724 | + | ||
| 712 | 725 | static struct PyMethodDef mmap_object_methods[] = { | |
| 713 | 726 | {"close", (PyCFunction) mmap_close_method, METH_NOARGS}, | |
| 714 | 727 | {"find", (PyCFunction) mmap_find_method, METH_VARARGS}, | |
@@ -726,6 +739,9 @@ static struct PyMethodDef mmap_object_methods[] = { | |||
| 726 | 739 | {"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS}, | |
| 727 | 740 | {"__enter__", (PyCFunction) mmap__enter__method, METH_NOARGS}, | |
| 728 | 741 | {"__exit__", (PyCFunction) mmap__exit__method, METH_VARARGS}, | |
| 742 | + #ifdef MS_WINDOWS | ||
| 743 | + {"__sizeof__", (PyCFunction) mmap__sizeof__method, METH_NOARGS}, | ||
| 744 | + #endif | ||
| 729 | 745 | {NULL, NULL} /* sentinel */ | |
| 730 | 746 | }; | |
| 731 | 747 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments