diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 55c6ad04d44d828..053a4ca4db53a57 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -59,6 +59,7 @@ def test_basic(self): f.flush() m = mmap.mmap(f.fileno(), 2 * PAGESIZE) self.addCleanup(m.close) + self.assertEqual(f.tell(), 2 * PAGESIZE) finally: f.close() diff --git a/Misc/NEWS.d/next/Windows/2026-08-09-17-30-00.gh-issue-68048.Mq8Vd4.rst b/Misc/NEWS.d/next/Windows/2026-08-09-17-30-00.gh-issue-68048.Mq8Vd4.rst new file mode 100644 index 000000000000000..12b5067ba934ec2 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-08-09-17-30-00.gh-issue-68048.Mq8Vd4.rst @@ -0,0 +1,2 @@ +Creating a :class:`mmap.mmap` object on Windows no longer resets the position +of the underlying file to zero, as on other platforms. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index e521e95d4ded73f..58f1e3b2ddcca70 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -2084,9 +2084,6 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) fh = _Py_get_osfhandle(fileno); if (fh == INVALID_HANDLE_VALUE) return NULL; - - /* Win9x appears to need us seeked to zero */ - lseek(fileno, 0, SEEK_SET); } m_obj = (mmap_object *)type->tp_alloc(type, 0);