Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-111926-thread-safe-weakref
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Mar 29, 2024
2 parents ed280d8 + 05e0b67 commit 2750787
Show file tree
Hide file tree
Showing 258 changed files with 8,342 additions and 4,906 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# sanitizer: [address, undefined, memory] -- memory skipped temporarily until GH-116886 is solved.
sanitizer: [address, undefined]
sanitizer: [address, undefined, memory]
steps:
- name: Build fuzzers (${{ matrix.sanitizer }})
id: build
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ on:
- '**jit**'
- 'Python/bytecodes.c'
- 'Python/optimizer*.c'
- 'Python/optimizer_bytecodes.c'
push:
paths:
- '**jit**'
- 'Python/bytecodes.c'
- 'Python/optimizer*.c'
- 'Python/optimizer_bytecodes.c'
workflow_dispatch:

concurrency:
Expand All @@ -22,7 +20,7 @@ jobs:
jit:
name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -95,7 +93,7 @@ jobs:
run: |
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
./PCbuild/rt.bat ${{ matrix.debug && '-d' }} -p ${{ matrix.architecture }} -q --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
# No PGO or tests (yet):
- name: Emulated Windows
Expand All @@ -111,7 +109,7 @@ jobs:
SDKROOT="$(xcrun --show-sdk-path)" \
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
make all --jobs 4
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
./python.exe -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
- name: Native Linux
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
Expand All @@ -120,7 +118,7 @@ jobs:
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
make all --jobs 4
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
- name: Emulated Linux
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
Expand All @@ -140,4 +138,4 @@ jobs:
HOSTRUNNER=qemu-${{ matrix.architecture }} \
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
make all --jobs 4
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 3600 --verbose2 --verbose3
./python -m test --exclude ${{ matrix.exclude }} --multiprocess 0 --timeout 4500 --verbose2 --verbose3
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.4
hooks:
- id: ruff
name: Run Ruff on Lib/test/
Expand All @@ -14,6 +14,8 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
exclude: ^Lib/test/test_tomllib/
- id: check-yaml
Expand Down
8 changes: 4 additions & 4 deletions Doc/c-api/bytes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ called with a non-bytes parameter.
.. c:function:: int _PyBytes_Resize(PyObject **bytes, Py_ssize_t newsize)
A way to resize a bytes object even though it is "immutable". Only use this
to build up a brand new bytes object; don't use this if the bytes may already
be known in other parts of the code. It is an error to call this function if
the refcount on the input bytes object is not one. Pass the address of an
Resize a bytes object. *newsize* will be the new length of the bytes object.
You can think of it as creating a new bytes object and destroying the old
one, only more efficiently.
Pass the address of an
existing bytes object as an lvalue (it may be written into), and the new size
desired. On success, *\*bytes* holds the resized bytes object and ``0`` is
returned; the address in *\*bytes* may differ from its input value. If the
Expand Down
1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Doc/includes/wasm-ios-notavail.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. include for modules that don't work on WASM or iOS
.. availability:: not WASI, not iOS.

This module does not work or is not available on WebAssembly platforms, or
on iOS. See :ref:`wasm-availability` for more information on WASM
availability; see :ref:`iOS-availability` for more information on iOS
availability.
5 changes: 2 additions & 3 deletions Doc/includes/wasm-notavail.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.. include for modules that don't work on WASM
.. availability:: not Emscripten, not WASI.
.. availability:: not WASI.

This module does not work or is not available on WebAssembly platforms
``wasm32-emscripten`` and ``wasm32-wasi``. See
This module does not work or is not available on WebAssembly. See
:ref:`wasm-availability` for more information.
31 changes: 31 additions & 0 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ may be treated as parts of multiline values or ignored.
By default, a valid section name can be any string that does not contain '\\n'.
To change this, see :attr:`ConfigParser.SECTCRE`.

The first section name may be omitted if the parser is configured to allow an
unnamed top level section with ``allow_unnamed_section=True``. In this case,
the keys/values may be retrieved by :const:`UNNAMED_SECTION` as in
``config[UNNAMED_SECTION]``.

Configuration files may include comments, prefixed by specific
characters (``#`` and ``;`` by default [1]_). Comments may appear on
their own on an otherwise empty line, possibly indented. [1]_
Expand Down Expand Up @@ -325,6 +330,27 @@ For example:
# Did I mention we can indent comments, too?
.. _unnamed-sections:

Unnamed Sections
----------------

The name of the first section (or unique) may be omitted and values
retrieved by the :const:`UNNAMED_SECTION` attribute.

.. doctest::

>>> config = """
... option = value
...
... [ Section 2 ]
... another = val
... """
>>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)
>>> unnamed.read_string(config)
>>> unnamed.get(configparser.UNNAMED_SECTION, 'option')
'value'

Interpolation of values
-----------------------

Expand Down Expand Up @@ -1216,6 +1242,11 @@ ConfigParser Objects
names is stripped before :meth:`optionxform` is called.


.. data:: UNNAMED_SECTION

A special object representing a section name used to reference the unnamed section (see :ref:`unnamed-sections`).


.. data:: MAX_INTERPOLATION_DEPTH

The maximum depth for recursive interpolation for :meth:`~configparser.ConfigParser.get` when the *raw*
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ for Windows, DOS, and possibly other systems as well. This extension module is
designed to match the API of ncurses, an open-source curses library hosted on
Linux and the BSD variants of Unix.

.. include:: ../includes/wasm-ios-notavail.rst

.. note::

Whenever the documentation mentions a *character* it can be specified
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/dbm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There
is a `third party interface <https://www.jcea.es/programacion/pybsddb.htm>`_ to
the Oracle Berkeley DB.

.. include:: ../includes/wasm-ios-notavail.rst

.. exception:: error

Expand Down Expand Up @@ -455,4 +456,3 @@ The :mod:`!dbm.dumb` module defines the following:
.. method:: dumbdbm.close()

Close the database.

2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ iterations of the loop.
except that ``namei`` is shifted left by 2 bits instead of 1.

The low bit of ``namei`` signals to attempt a method load, as with
:opcode:`LOAD_ATTR`, which results in pushing ``None`` and the loaded method.
:opcode:`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded method.
When it is unset a single value is pushed to the stack.

The second-low bit of ``namei``, if set, means that this was a two-argument
Expand Down
16 changes: 9 additions & 7 deletions Doc/library/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ And so on, eventually ending with:
OverflowError: n too large
ok
2 items passed all tests:
1 tests in __main__
8 tests in __main__.factorial
9 tests in 2 items.
9 passed and 0 failed.
1 test in __main__
6 tests in __main__.factorial
7 tests in 2 items.
7 passed.
Test passed.
$
Expand Down Expand Up @@ -1021,7 +1021,8 @@ from text files and modules with doctests:
and runs the interactive examples in each file. If an example in any file
fails, then the synthesized unit test fails, and a :exc:`failureException`
exception is raised showing the name of the file containing the test and a
(sometimes approximate) line number.
(sometimes approximate) line number. If all the examples in a file are
skipped, then the synthesized unit test is also marked as skipped.

Pass one or more paths (as strings) to text files to be examined.

Expand Down Expand Up @@ -1087,7 +1088,8 @@ from text files and modules with doctests:
and runs each doctest in the module. If any of the doctests fail, then the
synthesized unit test fails, and a :exc:`failureException` exception is raised
showing the name of the file containing the test and a (sometimes approximate)
line number.
line number. If all the examples in a docstring are skipped, then the
synthesized unit test is also marked as skipped.

Optional argument *module* provides the module to be tested. It can be a module
object or a (possibly dotted) module name. If not specified, the module calling
Expand Down Expand Up @@ -1933,7 +1935,7 @@ such a test runner::
optionflags=flags)
else:
fail, total = doctest.testmod(optionflags=flags)
print("{} failures out of {} tests".format(fail, total))
print(f"{fail} failures out of {total} tests")


.. rubric:: Footnotes
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ensurepip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ when creating a virtual environment) or after explicitly uninstalling
:pep:`453`: Explicit bootstrapping of pip in Python installations
The original rationale and specification for this module.

.. include:: ../includes/wasm-notavail.rst
.. include:: ../includes/wasm-ios-notavail.rst

Command line interface
----------------------
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/fcntl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines.
See the :manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages
for full details.

.. availability:: Unix, not Emscripten, not WASI.
.. availability:: Unix, not WASI.

All functions in this module take a file descriptor *fd* as their first
argument. This can be an integer file descriptor, such as returned by
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/grp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
This module provides access to the Unix group database. It is available on all
Unix versions.

.. availability:: Unix, not Emscripten, not WASI.
.. availability:: Unix, not WASI, not iOS.

Group database entries are reported as a tuple-like object, whose attributes
correspond to the members of the ``group`` structure (Attribute field below, see
Expand Down
23 changes: 10 additions & 13 deletions Doc/library/gzip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ The module defines the following items:
compression, and ``9`` is slowest and produces the most compression. ``0``
is no compression. The default is ``9``.

The *mtime* argument is an optional numeric timestamp to be written to
the last modification time field in the stream when compressing. It
should only be provided in compression mode. If omitted or ``None``, the
current time is used. See the :attr:`mtime` attribute for more details.
The optional *mtime* argument is the timestamp requested by gzip. The time
is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.
If *mtime* is omitted or None, the current time is used. Use *mtime* = 0
to generate a compressed stream that does not depend on creation time.

See below for the :attr:`mtime` attribute that is set when decompressing.

Calling a :class:`GzipFile` object's :meth:`!close` method does not close
*fileobj*, since you might wish to append more material after the compressed
Expand Down Expand Up @@ -133,15 +135,10 @@ The module defines the following items:

.. attribute:: mtime

When decompressing, the value of the last modification time field in
the most recently read header may be read from this attribute, as an
integer. The initial value before reading any headers is ``None``.

All :program:`gzip` compressed streams are required to contain this
timestamp field. Some programs, such as :program:`gunzip`\ , make use
of the timestamp. The format is the same as the return value of
:func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of
the object returned by :func:`os.stat`.
When decompressing, this attribute is set to the last timestamp in the most
recently read header. It is an integer, holding the number of seconds
since the Unix epoch (00:00:00 UTC, January 1, 1970).
The initial value before reading any headers is ``None``.

.. attribute:: name

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ retrieves and prints all messages::

import getpass, imaplib

M = imaplib.IMAP4()
M = imaplib.IMAP4(host='example.org')
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
Expand Down
43 changes: 42 additions & 1 deletion Doc/library/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Notes on availability
operating system.

* If not separately noted, all functions that claim "Availability: Unix" are
supported on macOS, which builds on a Unix core.
supported on macOS and iOS, both of which build on a Unix core.

* If an availability note contains both a minimum Kernel version and a minimum
libc version, then both conditions must hold. For example a feature with note
Expand Down Expand Up @@ -119,3 +119,44 @@ DOM APIs as well as limited networking capabilities with JavaScript's
.. _wasmtime: https://wasmtime.dev/
.. _Pyodide: https://pyodide.org/
.. _PyScript: https://pyscript.net/

.. _iOS-availability:

iOS
---

iOS is, in most respects, a POSIX operating system. File I/O, socket handling,
and threading all behave as they would on any POSIX operating system. However,
there are several major differences between iOS and other POSIX systems.

* iOS can only use Python in "embedded" mode. There is no Python REPL, and no
ability to execute binaries that are part of the normal Python developer
experience, such as :program:`pip`. To add Python code to your iOS app, you must use
the :ref:`Python embedding API <embedding>` to add a Python interpreter to an
iOS app created with Xcode. See the :ref:`iOS usage guide <using-ios>` for
more details.

* An iOS app cannot use any form of subprocessing, background processing, or
inter-process communication. If an iOS app attempts to create a subprocess,
the process creating the subprocess will either lock up, or crash. An iOS app
has no visibility of other applications that are running, nor any ability to
communicate with other running applications, outside of the iOS-specific APIs
that exist for this purpose.

* iOS apps have limited access to modify system resources (such as the system
clock). These resources will often be *readable*, but attempts to modify
those resources will usually fail.

* iOS apps have a limited concept of console input and output. ``stdout`` and
``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be
visible in logs when running in Xcode, but this content *won't* be recorded
in the system log. If a user who has installed your app provides their app
logs as a diagnostic aid, they will not include any detail written to
``stdout`` or ``stderr``.

iOS apps have no concept of ``stdin`` at all. While iOS apps can have a
keyboard, this is a software feature, not something that is attached to
``stdin``.

As a result, Python library that involve console manipulation (such as
:mod:`curses` and :mod:`readline`) are not available on iOS.
2 changes: 1 addition & 1 deletion Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

--------------

.. include:: ../includes/wasm-notavail.rst
.. include:: ../includes/wasm-ios-notavail.rst

Introduction
------------
Expand Down
Loading

0 comments on commit 2750787

Please sign in to comment.