Skip to content

Commit

Permalink
Merge branch 'python:main' into lock-macosx-multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesDup authored Jul 14, 2024
2 parents f8cdb79 + 5d6861a commit faa75c9
Show file tree
Hide file tree
Showing 180 changed files with 1,921 additions and 1,081 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV WASI_SDK_VERSION=21
ENV WASI_SDK_PATH=/opt/wasi-sdk

ENV WASMTIME_HOME=/opt/wasmtime
ENV WASMTIME_VERSION=18.0.3
ENV WASMTIME_VERSION=22.0.0
ENV WASMTIME_CPU_ARCH=x86_64

RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Include/internal/pycore_freelist.h @ericsnowcurrently
Include/internal/pycore_global_objects.h @ericsnowcurrently
Include/internal/pycore_obmalloc.h @ericsnowcurrently
Include/internal/pycore_pymem.h @ericsnowcurrently
Include/internal/pycore_stackref.h @Fidget-Spinner
Modules/main.c @ericsnowcurrently
Programs/_bootstrap_python.c @ericsnowcurrently
Programs/python.c @ericsnowcurrently
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ jobs:
path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/
key: hypothesis-database-${{ github.head_ref || github.run_id }}
restore-keys: |
- hypothesis-database-
hypothesis-database-
- name: "Run tests"
working-directory: ${{ env.CPYTHON_BUILDDIR }}
run: |
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-22.04
env:
WASMTIME_VERSION: 18.0.3
WASMTIME_VERSION: 22.0.0
WASI_SDK_VERSION: 21
WASI_SDK_PATH: /opt/wasi-sdk
CROSS_BUILD_PYTHON: cross-build/build
Expand All @@ -20,9 +20,9 @@ jobs:
- uses: actions/checkout@v4
# No problem resolver registered as one doesn't currently exist for Clang.
- name: "Install wasmtime"
uses: jcbhmr/setup-wasmtime@v2
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
wasmtime-version: ${{ env.WASMTIME_VERSION }}
version: ${{ env.WASMTIME_VERSION }}
- name: "Restore WASI SDK"
id: cache-wasi-sdk
uses: actions/cache@v4
Expand Down Expand Up @@ -50,8 +50,10 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
# (Make sure to keep the key in sync with the other config.cache step below.)
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
- name: "Configure build Python"
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
- name: "Make build Python"
Expand All @@ -60,8 +62,8 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
# Should be kept in sync with the other config.cache step above.
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
- name: "Configure host"
# `--with-pydebug` inferred from configure-build-python
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
Expand Down
9 changes: 6 additions & 3 deletions Doc/c-api/cell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Cell objects are not likely to be useful elsewhere.
.. c:function:: PyObject* PyCell_Get(PyObject *cell)
Return the contents of the cell *cell*.
Return the contents of the cell *cell*, which can be ``NULL``.
If *cell* is not a cell object, returns ``NULL`` with an exception set.
.. c:function:: PyObject* PyCell_GET(PyObject *cell)
Expand All @@ -52,8 +53,10 @@ Cell objects are not likely to be useful elsewhere.
Set the contents of the cell object *cell* to *value*. This releases the
reference to any current content of the cell. *value* may be ``NULL``. *cell*
must be non-``NULL``; if it is not a cell object, ``-1`` will be returned. On
success, ``0`` will be returned.
must be non-``NULL``.
On success, return ``0``.
If *cell* is not a cell object, set an exception and return ``-1``.
.. c:function:: void PyCell_SET(PyObject *cell, PyObject *value)
Expand Down
25 changes: 16 additions & 9 deletions Doc/c-api/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Module Objects
to ``None``); the caller is responsible for providing a :attr:`__file__`
attribute.
Return ``NULL`` with an exception set on error.
.. versionadded:: 3.3
.. versionchanged:: 3.4
Expand Down Expand Up @@ -265,6 +267,8 @@ of the following two module creation functions:
API version *module_api_version*. If that version does not match the version
of the running interpreter, a :exc:`RuntimeWarning` is emitted.
Return ``NULL`` with an exception set on error.
.. note::
Most uses of this function should be using :c:func:`PyModule_Create`
Expand Down Expand Up @@ -461,6 +465,8 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
If that version does not match the version of the running interpreter,
a :exc:`RuntimeWarning` is emitted.
Return ``NULL`` with an exception set on error.
.. note::
Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec`
Expand Down Expand Up @@ -511,7 +517,7 @@ state:
On success, return ``0``. On error, raise an exception and return ``-1``.
Return ``NULL`` if *value* is ``NULL``. It must be called with an exception
Return ``-1`` if *value* is ``NULL``. It must be called with an exception
raised in this case.
Example usage::
Expand Down Expand Up @@ -601,23 +607,24 @@ state:
.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
Add an integer constant to *module* as *name*. This convenience function can be
used from the module's initialization function. Return ``-1`` on error, ``0`` on
success.
used from the module's initialization function.
Return ``-1`` with an exception set on error, ``0`` on success.
.. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
Add a string constant to *module* as *name*. This convenience function can be
used from the module's initialization function. The string *value* must be
``NULL``-terminated. Return ``-1`` on error, ``0`` on success.
``NULL``-terminated.
Return ``-1`` with an exception set on error, ``0`` on success.
.. c:macro:: PyModule_AddIntMacro(module, macro)
Add an int constant to *module*. The name and the value are taken from
*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
constant *AF_INET* with the value of *AF_INET* to *module*.
Return ``-1`` on error, ``0`` on success.
Return ``-1`` with an exception set on error, ``0`` on success.
.. c:macro:: PyModule_AddStringMacro(module, macro)
Expand All @@ -630,7 +637,7 @@ state:
The type object is finalized by calling internally :c:func:`PyType_Ready`.
The name of the type object is taken from the last component of
:c:member:`~PyTypeObject.tp_name` after dot.
Return ``-1`` on error, ``0`` on success.
Return ``-1`` with an exception set on error, ``0`` on success.
.. versionadded:: 3.9
Expand All @@ -643,7 +650,7 @@ state:
import machinery assumes the module does not support running without the
GIL. This function is only available in Python builds configured with
:option:`--disable-gil`.
Return ``-1`` on error, ``0`` on success.
Return ``-1`` with an exception set on error, ``0`` on success.
.. versionadded:: 3.13
Expand Down Expand Up @@ -682,14 +689,14 @@ since multiple such modules can be created from a single definition.
The caller must hold the GIL.
Return 0 on success or -1 on failure.
Return ``-1`` with an exception set on error, ``0`` on success.
.. versionadded:: 3.3
.. c:function:: int PyState_RemoveModule(PyModuleDef *def)
Removes the module object created from *def* from the interpreter state.
Return 0 on success or -1 on failure.
Return ``-1`` with an exception set on error, ``0`` on success.
The caller must hold the GIL.
Expand Down
1 change: 1 addition & 0 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Object Protocol
The reference is borrowed from the interpreter, and is valid until the
interpreter finalization.
.. versionadded:: 3.13
Expand Down
8 changes: 5 additions & 3 deletions Doc/c-api/slice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Slice Objects
Return a new slice object with the given values. The *start*, *stop*, and
*step* parameters are used as the values of the slice object attributes of
the same names. Any of the values may be ``NULL``, in which case the
``None`` will be used for the corresponding attribute. Return ``NULL`` if
``None`` will be used for the corresponding attribute.
Return ``NULL`` with an exception set if
the new object could not be allocated.
Expand Down Expand Up @@ -52,7 +54,7 @@ Slice Objects
of bounds indices are clipped in a manner consistent with the handling of
normal slices.
Returns ``0`` on success and ``-1`` on error with exception set.
Return ``0`` on success and ``-1`` on error with an exception set.
.. note::
This function is considered not safe for resizable sequences.
Expand Down Expand Up @@ -95,7 +97,7 @@ Slice Objects
``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step
values less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``.
Return ``-1`` on error, ``0`` on success.
Return ``-1`` with an exception set on error, ``0`` on success.
.. versionadded:: 3.6.1
Expand Down
3 changes: 3 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
('c:data', 'PyExc_UnicodeWarning'),
('c:data', 'PyExc_UserWarning'),
('c:data', 'PyExc_Warning'),
# Undocumented public C macros
('c:macro', 'Py_BUILD_ASSERT'),
('c:macro', 'Py_BUILD_ASSERT_EXPR'),
# Do not error nit-picky mode builds when _SubParsersAction.add_parser cannot
# be resolved, as the method is currently undocumented. For context, see
# https://github.com/python/cpython/pull/103289.
Expand Down
28 changes: 24 additions & 4 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1741,11 +1741,31 @@ but effective way to define class private variables. Any identifier of the form
is textually replaced with ``_classname__spam``, where ``classname`` is the
current class name with any leading underscores stripped.

This doesn't guarantee privacy: an outside user can still deliberately access
the "_classname__spam" attribute, and private values are visible in the object's
``__dict__``. Many Python programmers never bother to use private variable
names at all.
The identifier can be used unchanged within the class, but to access it outside
the class, the mangled name must be used:

.. code-block:: python
class A:
def __one(self):
return 1
def two(self):
return 2 * self.__one()
class B(A):
def three(self):
return 3 * self._A__one()
four = 4 * A()._A__one()
In particular, this does not guarantee privacy since an outside user can still
deliberately access the private attribute; many Python programmers never bother
to use private variable names at all.

.. seealso::

The :ref:`private name mangling specifications <private-name-mangling>`
for details and special cases.

My class defines __del__ but it is not called when I delete the object.
-----------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,9 @@ Executing code in thread or process pools

The *executor* argument should be an :class:`concurrent.futures.Executor`
instance. The default executor is used if *executor* is ``None``.
The default executor can be set by :meth:`loop.set_default_executor`,
otherwise, a :class:`concurrent.futures.ThreadPoolExecutor` will be
lazy-initialized and used by :func:`run_in_executor` if needed.

Example::

Expand Down
58 changes: 44 additions & 14 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,28 @@ case-insensitive and stored in lowercase [1]_.
It is possible to read several configurations into a single
:class:`ConfigParser`, where the most recently added configuration has the
highest priority. Any conflicting keys are taken from the more recent
configuration while the previously existing keys are retained.
configuration while the previously existing keys are retained. The example
below reads in an ``override.ini`` file, which will override any conflicting
keys from the ``example.ini`` file.

.. code-block:: ini
[DEFAULT]
ServerAliveInterval = -1
.. doctest::

>>> another_config = configparser.ConfigParser()
>>> another_config.read('example.ini')
['example.ini']
>>> another_config['topsecret.server.example']['Port']
'50022'
>>> another_config.read_string("[topsecret.server.example]\nPort=48484")
>>> another_config['topsecret.server.example']['Port']
'48484'
>>> another_config.read_dict({"topsecret.server.example": {"Port": 21212}})
>>> another_config['topsecret.server.example']['Port']
'21212'
>>> another_config['topsecret.server.example']['ForwardX11']
'no'
>>> config_override = configparser.ConfigParser()
>>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}
>>> with open('override.ini', 'w') as configfile:
... config_override.write(configfile)
...
>>> config_override = configparser.ConfigParser()
>>> config_override.read(['example.ini', 'override.ini'])
['example.ini', 'override.ini']
>>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))
-1


This behaviour is equivalent to a :meth:`ConfigParser.read` call with several
files passed to the *filenames* parameter.
Expand Down Expand Up @@ -984,6 +989,31 @@ ConfigParser Objects
converter gets its own corresponding :meth:`!get*()` method on the parser
object and section proxies.

It is possible to read several configurations into a single
:class:`ConfigParser`, where the most recently added configuration has the
highest priority. Any conflicting keys are taken from the more recent
configuration while the previously existing keys are retained. The example
below reads in an ``override.ini`` file, which will override any conflicting
keys from the ``example.ini`` file.

.. code-block:: ini
[DEFAULT]
ServerAliveInterval = -1
.. doctest::

>>> config_override = configparser.ConfigParser()
>>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}
>>> with open('override.ini', 'w') as configfile:
... config_override.write(configfile)
...
>>> config_override = configparser.ConfigParser()
>>> config_override.read(['example.ini', 'override.ini'])
['example.ini', 'override.ini']
>>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))
-1

.. versionchanged:: 3.1
The default *dict_type* is :class:`collections.OrderedDict`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ftplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ FTP objects
Retrieve a file in binary transfer mode.

:param str cmd:
An appropriate ``STOR`` command: :samp:`"STOR {filename}"`.
An appropriate ``RETR`` command: :samp:`"RETR {filename}"`.

:param callback:
A single parameter callable that is called
Expand Down
Loading

0 comments on commit faa75c9

Please sign in to comment.