Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 #111368

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
03335e6
use RESUME oparg to store exception depth info
iritkatriel Oct 26, 2023
8b4e89d
remove the arg from YIELD_VALUE
iritkatriel Oct 26, 2023
84fbfc3
add docs
iritkatriel Oct 26, 2023
3a111ab
fix test_dis
iritkatriel Oct 26, 2023
6005db5
add news
iritkatriel Oct 26, 2023
00a0cef
regen-all
iritkatriel Oct 26, 2023
50e2d25
Merge branch 'main' into gen_close
iritkatriel Oct 26, 2023
59b3cce
regen-all
iritkatriel Oct 26, 2023
dd8af2d
Merge branch 'main' into gen_close
iritkatriel Oct 27, 2023
c4b4583
Fix typos in import system docs (#111396)
jonathanberthias Oct 27, 2023
c48ec85
gh-111406: Fix broken link to bpython's site (#111407)
zmc Oct 27, 2023
64ca0a9
gh-108765: Include explicitly <unistd.h> in signalmodule.c (#111402)
vstinner Oct 27, 2023
3aeffca
gh-59013: Make line number of function breakpoint more precise (#110582)
gaogaotiantian Oct 27, 2023
2e74589
gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (#110884)
gvanrossum Oct 27, 2023
1b70f83
gh-111342: fix typo in math.sumprod (GH-111416)
skirpichev Oct 28, 2023
b632fc1
CI: Include Python version in cache.config key (#111410)
hugovk Oct 28, 2023
c483c69
gh-79033: Try to fix asyncio.Server.wait_closed() again (GH-111336)
gvanrossum Oct 28, 2023
5c9882e
GH-110109: Move tests for `pathlib.Path.walk()` into main test classe…
barneygale Oct 28, 2023
d5ec031
gh-111426: Remove `test_cmd.test_coverage` (#111427)
sobolevn Oct 28, 2023
31a9dcf
gh-66425: Remove the unreachable code to set `REMOTE_HOST` header (gh…
c-bata Oct 29, 2023
8d5134b
gh-111062: Separate macOS build into a reusable workflow (gh-111444)
dimaqq Oct 29, 2023
f2fc8ee
gh-94808: Add coverage test for number check (gh-111445)
ekohilas Oct 29, 2023
5499901
gh-111062: Build both default and free-threaded on macOS (gh-111449)
dimaqq Oct 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 17 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
- '3.10'
- '3.9'
- '3.8'
- '3.7'
pull_request:
branches:
- 'main'
Expand All @@ -22,7 +21,6 @@ on:
- '3.10'
- '3.9'
- '3.8'
- '3.7'

permissions:
contents: read
Expand Down Expand Up @@ -128,14 +126,14 @@ jobs:
if: needs.check_source.outputs.run_tests == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Restore config.cache
uses: actions/cache@v3
with:
path: config.cache
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
- uses: actions/setup-python@v4
with:
python-version: '3.x'
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
- name: Install Dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Add ccache to PATH
Expand Down Expand Up @@ -233,39 +231,20 @@ jobs:

build_macos:
name: 'macOS'
runs-on: macos-latest
timeout-minutes: 60
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
- name: Restore config.cache
uses: actions/cache@v3
with:
path: config.cache
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
- name: Install Homebrew dependencies
run: brew install pkg-config openssl@3.0 xz gdbm tcl-tk
- name: Configure CPython
run: |
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
./configure \
--config-cache \
--with-pydebug \
--prefix=/opt/python-dev \
--with-openssl="$(brew --prefix openssl@3.0)"
- name: Build CPython
run: make -j4
- name: Display build info
run: make pythoninfo
- name: Tests
run: make test
uses: ./.github/workflows/reusable-build-macos.yml
with:
config_hash: ${{ needs.check_source.outputs.config_hash }}

build_macos_free_threaded:
name: 'macOS (free-threaded)'
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
uses: ./.github/workflows/reusable-build-macos.yml
with:
config_hash: ${{ needs.check_source.outputs.config_hash }}
free-threaded: true

build_ubuntu:
name: 'Ubuntu'
Expand All @@ -280,7 +259,7 @@ jobs:
- uses: actions/checkout@v4
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install Dependencies
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Configure OpenSSL env vars
run: |
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/reusable-build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
workflow_call:
inputs:
config_hash:
required: true
type: string
free-threaded:
required: false
type: boolean
default: false

jobs:
build_macos:
runs-on: macos-latest
timeout-minutes: 60
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
- name: Restore config.cache
uses: actions/cache@v3
with:
path: config.cache
key: ${{ github.job }}-${{ runner.os }}-${{ inputs.config_hash }}
- name: Install Homebrew dependencies
run: brew install pkg-config openssl@3.0 xz gdbm tcl-tk
- name: Configure CPython
run: |
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
./configure \
--config-cache \
--with-pydebug \
${{ inputs.free-threaded && '--disable-gil' || '' }} \
--prefix=/opt/python-dev \
--with-openssl="$(brew --prefix openssl@3.0)"
- name: Build CPython
run: make -j4
- name: Display build info
run: make pythoninfo
- name: Tests
run: make test
8 changes: 5 additions & 3 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1619,8 +1619,9 @@ Do not instantiate the :class:`Server` class directly.
The sockets that represent existing incoming client connections
are left open.

The server is closed asynchronously, use the :meth:`wait_closed`
coroutine to wait until the server is closed.
The server is closed asynchronously; use the :meth:`wait_closed`
coroutine to wait until the server is closed (and no more
connections are active).

.. method:: get_loop()

Expand Down Expand Up @@ -1678,7 +1679,8 @@ Do not instantiate the :class:`Server` class directly.

.. coroutinemethod:: wait_closed()

Wait until the :meth:`close` method completes.
Wait until the :meth:`close` method completes and all active
connections have finished.

.. attribute:: sockets

Expand Down
12 changes: 9 additions & 3 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ iterations of the loop.
.. versionchanged:: 3.12
oparg set to be the exception block depth, for efficient closing of generators.

.. versionchanged:: 3.13
this opcode no longer has an oparg

.. opcode:: SETUP_ANNOTATIONS

Expand Down Expand Up @@ -1633,12 +1635,16 @@ iterations of the loop.

* ``0`` The start of a function, which is neither a generator, coroutine
nor an async generator
* ``1`` After a ``yield`` expression
* ``2`` After a ``yield from`` expression
* ``3`` After an ``await`` expression
* ``1`` After a ``yield`` expression, with except-depth > 1
* ``2`` After a ``yield`` expression, with except-depth 1
* ``3`` After a ``yield from`` expression
* ``4`` After an ``await`` expression

.. versionadded:: 3.11

.. versionchanged:: 3.13
new oparg value for ``RESUME`` after ``YIELD_VALUE`` with except-depth of 1


.. opcode:: RETURN_GENERATOR

Expand Down
6 changes: 3 additions & 3 deletions Doc/reference/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ listed below.
functionality, for example getting data associated with a loader.

It is **strongly** recommended that you rely on :attr:`__spec__`
instead instead of this attribute.
instead of this attribute.

.. versionchanged:: 3.12
The value of ``__loader__`` is expected to be the same as
Expand All @@ -580,7 +580,7 @@ listed below.
relative imports for main modules, as defined in :pep:`366`.

It is **strongly** recommended that you rely on :attr:`__spec__`
instead instead of this attribute.
instead of this attribute.

.. versionchanged:: 3.6
The value of ``__package__`` is expected to be the same as
Expand Down Expand Up @@ -650,7 +650,7 @@ listed below.
from a file, that atypical scenario may be appropriate.

It is **strongly** recommended that you rely on :attr:`__spec__`
instead instead of ``__cached__``.
instead of ``__cached__``.

.. _package-path-rules:

Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ bpython_.

.. _GNU Readline: https://tiswww.case.edu/php/chet/readline/rltop.html
.. _IPython: https://ipython.org/
.. _bpython: https://www.bpython-interpreter.org/
.. _bpython: https://bpython-interpreter.org/
12 changes: 11 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,15 @@ Others

* None yet

CPython bytecode changes
========================

* ``YIELD_VALUE`` no longer has an oparg. The set of possible values
for the oparg of ``RESUME`` was changed to add a new value which
identifies a ``RESUME`` that follows a ``YIELD_VALUE`` which is at
except-depth of 1. (This is needed to optimize closing of generators.)
(Contributed by Irit Katriel in :gh:`111354`.)

Porting to Python 3.13
======================

Expand Down Expand Up @@ -1120,7 +1129,8 @@ Porting to Python 3.13
* ``Python.h`` no longer includes the ``<unistd.h>`` standard header file. If
needed, it should now be included explicitly. For example, it provides the
functions: ``read()``, ``write()``, ``close()``, ``isatty()``, ``lseek()``,
``getpid()``, ``getcwd()``, ``sysconf()`` and ``getpagesize()``.
``getpid()``, ``getcwd()``, ``sysconf()``, ``getpagesize()``, ``alarm()`` and
``pause()``.
As a consequence, ``_POSIX_SEMAPHORES`` and ``_POSIX_THREADS`` macros are no
longer defined by ``Python.h``. The ``HAVE_UNISTD_H`` and ``HAVE_PTHREAD_H``
macros defined by ``Python.h`` can be used to decide if ``<unistd.h>`` and
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_opcode_metadata.h

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

5 changes: 3 additions & 2 deletions Include/internal/pycore_opcode_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ extern "C" {
/* Values used in the oparg for RESUME */
#define RESUME_AT_FUNC_START 0
#define RESUME_AFTER_YIELD 1
#define RESUME_AFTER_YIELD_FROM 2
#define RESUME_AFTER_AWAIT 3
#define RESUME_AFTER_YIELD_EXC_DEPTH_1 2
#define RESUME_AFTER_YIELD_FROM 3
#define RESUME_AFTER_AWAIT 4


#ifdef __cplusplus
Expand Down