Skip to content

Commit

Permalink
Catch up with main
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher committed Jan 16, 2024
2 parents 0bba20f + 2e672f7 commit b4474d0
Show file tree
Hide file tree
Showing 87 changed files with 1,075 additions and 396 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ jobs:
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: Configure CPython
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
- name: Build CPython
Expand Down
34 changes: 34 additions & 0 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,40 @@ definition with the same method name.
slot. This is helpful because calls to PyCFunctions are optimized more
than wrapper object calls.
.. c:function:: PyObject * PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *cls)
Turn *ml* into a Python :term:`callable` object.
The caller must ensure that *ml* outlives the :term:`callable`.
Typically, *ml* is defined as a static variable.
The *self* parameter will be passed as the *self* argument
to the C function in ``ml->ml_meth`` when invoked.
*self* can be ``NULL``.
The :term:`callable` object's ``__module__`` attribute
can be set from the given *module* argument.
*module* should be a Python string,
which will be used as name of the module the function is defined in.
If unavailable, it can be set to :const:`None` or ``NULL``.
.. seealso:: :attr:`function.__module__`
The *cls* parameter will be passed as the *defining_class*
argument to the C function.
Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``.
.. versionadded:: 3.9
.. c:function:: PyObject * PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
Equivalent to ``PyCMethod_New(ml, self, module, NULL)``.
.. c:function:: PyObject * PyCFunction_New(PyMethodDef *ml, PyObject *self)
Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``.
Accessing attributes of extension types
---------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Doc/copyright.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright

Python and this documentation is:

Copyright © 2001-2023 Python Software Foundation. All rights reserved.
Copyright © 2001-2024 Python Software Foundation. All rights reserved.

Copyright © 2000 BeOpen.com. All rights reserved.

Expand Down
15 changes: 15 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,21 @@ PyContextVar_Reset:int:::
PyContextVar_Reset:PyObject*:var:0:
PyContextVar_Reset:PyObject*:token:-1:

PyCFunction_New:PyObject*::+1:
PyCFunction_New:PyMethodDef*:ml::
PyCFunction_New:PyObject*:self:+1:

PyCFunction_NewEx:PyObject*::+1:
PyCFunction_NewEx:PyMethodDef*:ml::
PyCFunction_NewEx:PyObject*:self:+1:
PyCFunction_NewEx:PyObject*:module:+1:

PyCMethod_New:PyObject*::+1:
PyCMethod_New:PyMethodDef*:ml::
PyCMethod_New:PyObject*:self:+1:
PyCMethod_New:PyObject*:module:+1:
PyCMethod_New:PyObject*:cls:+1:

PyDate_Check:int:::
PyDate_Check:PyObject*:ob:0:

Expand Down
41 changes: 31 additions & 10 deletions Doc/library/marshal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ transfer of Python objects through RPC calls, see the modules :mod:`pickle` and
:mod:`shelve`. The :mod:`marshal` module exists mainly to support reading and
writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files.
Therefore, the Python maintainers reserve the right to modify the marshal format
in backward incompatible ways should the need arise. If you're serializing and
in backward incompatible ways should the need arise.
The format of code objects is not compatible between Python versions,
even if the version of the format is the same.
De-serializing a code object in the incorrect Python version has undefined behavior.
If you're serializing and
de-serializing Python objects, use the :mod:`pickle` module instead -- the
performance is comparable, version independence is guaranteed, and pickle
supports a substantially wider range of objects than marshal.
Expand All @@ -40,7 +44,8 @@ Not all Python object types are supported; in general, only objects whose value
is independent from a particular invocation of Python can be written and read by
this module. The following types are supported: booleans, integers, floating
point numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets,
frozensets, dictionaries, and code objects, where it should be understood that
frozensets, dictionaries, and code objects (if *allow_code* is true),
where it should be understood that
tuples, lists, sets, frozensets and dictionaries are only supported as long as
the values contained therein are themselves supported. The
singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration` can also be
Expand All @@ -54,27 +59,32 @@ bytes-like objects.
The module defines these functions:


.. function:: dump(value, file[, version])
.. function:: dump(value, file, version=version, /, *, allow_code=True)

Write the value on the open file. The value must be a supported type. The
file must be a writeable :term:`binary file`.

If the value has (or contains an object that has) an unsupported type, a
:exc:`ValueError` exception is raised --- but garbage data will also be written
to the file. The object will not be properly read back by :func:`load`.
:ref:`Code objects <code-objects>` are only supported if *allow_code* is true.

The *version* argument indicates the data format that ``dump`` should use
(see below).

.. audit-event:: marshal.dumps value,version marshal.dump

.. versionchanged:: 3.13
Added the *allow_code* parameter.

.. function:: load(file)

.. function:: load(file, /, *, allow_code=True)

Read one value from the open file and return it. If no valid value is read
(e.g. because the data has a different Python version's incompatible marshal
format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The
file must be a readable :term:`binary file`.
format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`.
:ref:`Code objects <code-objects>` are only supported if *allow_code* is true.
The file must be a readable :term:`binary file`.

.. audit-event:: marshal.load "" marshal.load

Expand All @@ -88,24 +98,32 @@ The module defines these functions:
This call used to raise a ``code.__new__`` audit event for each code object. Now
it raises a single ``marshal.load`` event for the entire load operation.

.. versionchanged:: 3.13
Added the *allow_code* parameter.


.. function:: dumps(value[, version])
.. function:: dumps(value, version=version, /, *, allow_code=True)

Return the bytes object that would be written to a file by ``dump(value, file)``. The
value must be a supported type. Raise a :exc:`ValueError` exception if value
has (or contains an object that has) an unsupported type.
:ref:`Code objects <code-objects>` are only supported if *allow_code* is true.

The *version* argument indicates the data format that ``dumps`` should use
(see below).

.. audit-event:: marshal.dumps value,version marshal.dump

.. versionchanged:: 3.13
Added the *allow_code* parameter.

.. function:: loads(bytes)

.. function:: loads(bytes, /, *, allow_code=True)

Convert the :term:`bytes-like object` to a value. If no valid value is found, raise
:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. Extra bytes in the
input are ignored.
:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`.
:ref:`Code objects <code-objects>` are only supported if *allow_code* is true.
Extra bytes in the input are ignored.

.. audit-event:: marshal.loads bytes marshal.load

Expand All @@ -114,6 +132,9 @@ The module defines these functions:
This call used to raise a ``code.__new__`` audit event for each code object. Now
it raises a single ``marshal.loads`` event for the entire load operation.

.. versionchanged:: 3.13
Added the *allow_code* parameter.


In addition, the following constants are defined:

Expand Down
24 changes: 19 additions & 5 deletions Doc/library/mmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ update the underlying file.

To map anonymous memory, -1 should be passed as the fileno along with the length.

.. class:: mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT[, offset])
.. class:: mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT, offset=0)

**(Windows version)** Maps *length* bytes from the file specified by the
file handle *fileno*, and creates a mmap object. If *length* is larger
Expand All @@ -71,7 +71,8 @@ To map anonymous memory, -1 should be passed as the fileno along with the length

.. audit-event:: mmap.__new__ fileno,length,access,offset mmap.mmap

.. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, access=ACCESS_DEFAULT[, offset])
.. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \
access=ACCESS_DEFAULT, offset=0, *, trackfd=True)
:noindex:
**(Unix version)** Maps *length* bytes from the file specified by the file
Expand Down Expand Up @@ -102,10 +103,20 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
defaults to 0. *offset* must be a multiple of :const:`ALLOCATIONGRANULARITY`
which is equal to :const:`PAGESIZE` on Unix systems.

If *trackfd* is ``False``, the file descriptor specified by *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be associated with the map's underlying file.
This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize`
methods will fail.
This mode is useful to limit the number of open file descriptors.

To ensure validity of the created memory mapping the file specified
by the descriptor *fileno* is internally automatically synchronized
with the physical backing store on macOS.

.. versionchanged:: 3.13
The *trackfd* parameter was added.

This example shows a simple way of using :class:`~mmap.mmap`::

import mmap
Expand Down Expand Up @@ -254,9 +265,12 @@ To map anonymous memory, -1 should be passed as the fileno along with the length

.. method:: resize(newsize)

Resizes the map and the underlying file, if any. If the mmap was created
with :const:`ACCESS_READ` or :const:`ACCESS_COPY`, resizing the map will
raise a :exc:`TypeError` exception.
Resizes the map and the underlying file, if any.

Resizing a map created with *access* of :const:`ACCESS_READ` or
:const:`ACCESS_COPY`, will raise a :exc:`TypeError` exception.
Resizing a map created with with *trackfd* set to ``False``,
will raise a :exc:`ValueError` exception.

**On Windows**: Resizing the map will raise an :exc:`OSError` if there are other
maps against the same named file. Resizing an anonymous map (ie against the
Expand Down
Loading

0 comments on commit b4474d0

Please sign in to comment.