Skip to content

Commit a4d932c

Browse files
authored
[3.14] gh-151950: Fix Sphinx references in mmap documentation (GH-153764) (#160081)
1 parent 3a08d02 commit a4d932c

2 files changed

Lines changed: 51 additions & 5 deletions

File tree

‎Doc/library/mmap.rst‎

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ where :class:`bytearray` are expected; for example, you can use the :mod:`re`
1414
module to search through a memory-mapped file. You can also change a single
1515
byte by doing ``obj[index] = 97``, or change a subsequence by assigning to a
1616
slice: ``obj[i1:i2] = b'...'``. You can also read and write data starting at
17-
the current file position, and :meth:`seek` through the file to different positions.
17+
the current file position, and :meth:`~mmap.mmap.seek` through the file to
18+
different positions.
1819

1920
A memory-mapped file is created by the :class:`~mmap.mmap` constructor, which is
2021
different on Unix and on Windows. In either case you must provide a file
@@ -91,7 +92,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
9192
*prot*, if specified, gives the desired memory protection; the two most
9293
useful values are :const:`PROT_READ` and :const:`PROT_WRITE`, to specify
9394
that the pages may be read or written. *prot* defaults to
94-
:const:`PROT_READ \| PROT_WRITE`.
95+
:const:`PROT_READ` \| :const:`PROT_WRITE`.
9596

9697
*access* may be specified in lieu of *flags* and *prot* as an optional
9798
keyword parameter. It is an error to specify both *flags*, *prot* and
@@ -343,9 +344,55 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
343344
the mmap was created with :const:`ACCESS_READ`, then writing to it will
344345
raise a :exc:`TypeError` exception.
345346

347+
.. _access-constants:
348+
349+
ACCESS_* constants
350+
++++++++++++++++++
351+
352+
.. data:: ACCESS_DEFAULT
353+
ACCESS_READ
354+
ACCESS_WRITE
355+
ACCESS_COPY
356+
357+
These constants specify the access mode for a memory mapping.
358+
:const:`ACCESS_READ` provides read-only access, :const:`ACCESS_WRITE`
359+
provides write-through access, and :const:`ACCESS_COPY` provides
360+
copy-on-write access. :const:`ACCESS_DEFAULT` defers to the *prot*
361+
argument of :class:`mmap`.
362+
363+
.. _page-size-constants:
364+
365+
Page size constants
366+
+++++++++++++++++++
367+
368+
.. data:: PAGESIZE
369+
ALLOCATIONGRANULARITY
370+
371+
:const:`PAGESIZE` is the system memory page size in bytes.
372+
:const:`ALLOCATIONGRANULARITY` is the minimum alignment in bytes required
373+
for the *offset* argument of :class:`mmap`. On Unix,
374+
:const:`ALLOCATIONGRANULARITY` is equal to :const:`PAGESIZE`.
375+
376+
.. _prot-constants:
377+
378+
PROT_* constants
379+
++++++++++++++++
380+
381+
.. data:: PROT_READ
382+
PROT_WRITE
383+
PROT_EXEC
384+
385+
Memory protection flags accepted by the *prot* argument of :class:`mmap`.
386+
:const:`PROT_READ` allows pages to be read, :const:`PROT_WRITE` allows pages
387+
to be written, and :const:`PROT_EXEC` allows pages to be executed. Values
388+
can be combined using the bitwise OR operator. Not every option is present
389+
on every system.
390+
391+
.. availability:: Unix.
392+
346393
.. _madvise-constants:
347394

348-
MADV_* Constants
395+
MADV_* constants
349396
++++++++++++++++
350397

351398
.. data:: MADV_NORMAL
@@ -382,7 +429,7 @@ MADV_* Constants
382429

383430
.. _map-constants:
384431

385-
MAP_* Constants
432+
MAP_* constants
386433
+++++++++++++++
387434

388435
.. data:: MAP_SHARED

‎Doc/tools/.nitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Doc/library/email.charset.rst
99
Doc/library/email.parser.rst
1010
Doc/library/logging.config.rst
1111
Doc/library/logging.handlers.rst
12-
Doc/library/mmap.rst
1312
Doc/library/multiprocessing.rst
1413
Doc/library/optparse.rst
1514
Doc/library/os.rst

0 commit comments

Comments
 (0)