diff --git a/.github/workflows/add-issue-header.yml b/.github/workflows/add-issue-header.yml index 00b7ae50cb9935..4c25976b9c24f7 100644 --- a/.github/workflows/add-issue-header.yml +++ b/.github/workflows/add-issue-header.yml @@ -12,7 +12,8 @@ on: # Only ever run once - opened -permissions: {} +permissions: + contents: read jobs: add-header: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c34f8f699d8edb..9303190ea6dbba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,8 @@ on: - 'main' - '3.*' -permissions: {} +permissions: + contents: read concurrency: # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency @@ -612,6 +613,7 @@ jobs: needs.build-context.outputs.run-ci-fuzz == 'true' || needs.build-context.outputs.run-ci-fuzz-stdlib == 'true' permissions: + contents: read security-events: write strategy: fail-fast: false diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml index 81d75ef1820903..e63fe9e1284a01 100644 --- a/.github/workflows/jit.yml +++ b/.github/workflows/jit.yml @@ -15,7 +15,8 @@ on: paths: *paths workflow_dispatch: -permissions: {} +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fb2b94b7362308..e9a4eb2b0808cb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,8 @@ name: Lint on: [push, pull_request, workflow_dispatch] -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 583dc1808dfc35..e5a5b3939e58e3 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -33,7 +33,8 @@ on: - "Tools/requirements-dev.txt" workflow_dispatch: -permissions: {} +permissions: + contents: read env: PIP_DISABLE_PIP_VERSION_CHECK: 1 diff --git a/.github/workflows/new-bugs-announce-notifier.yml b/.github/workflows/new-bugs-announce-notifier.yml index be375a970a475c..1267361040c81b 100644 --- a/.github/workflows/new-bugs-announce-notifier.yml +++ b/.github/workflows/new-bugs-announce-notifier.yml @@ -5,7 +5,8 @@ on: types: - opened -permissions: {} +permissions: + contents: read jobs: notify-new-bugs-announce: diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml index 262299fc30f989..f3e2666879530f 100644 --- a/.github/workflows/require-pr-label.yml +++ b/.github/workflows/require-pr-label.yml @@ -4,7 +4,8 @@ on: pull_request: types: [opened, reopened, labeled, unlabeled, synchronize] -permissions: {} +permissions: + contents: read jobs: label-dnm: diff --git a/.github/workflows/reusable-check-c-api-docs.yml b/.github/workflows/reusable-check-c-api-docs.yml index 5fae57a1dbda36..49e5ef7f768b79 100644 --- a/.github/workflows/reusable-check-c-api-docs.yml +++ b/.github/workflows/reusable-check-c-api-docs.yml @@ -3,7 +3,8 @@ name: Reusable C API Docs Check on: workflow_call: -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-check-html-ids.yml b/.github/workflows/reusable-check-html-ids.yml index 03ed714ca585fe..4f827c55cacd06 100644 --- a/.github/workflows/reusable-check-html-ids.yml +++ b/.github/workflows/reusable-check-html-ids.yml @@ -3,7 +3,8 @@ name: Reusable check HTML IDs on: workflow_call: -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-cifuzz.yml b/.github/workflows/reusable-cifuzz.yml index 093b2c859eff7b..0d02232686339b 100644 --- a/.github/workflows/reusable-cifuzz.yml +++ b/.github/workflows/reusable-cifuzz.yml @@ -13,7 +13,8 @@ on: required: true type: string -permissions: {} +permissions: + contents: read jobs: cifuzz: diff --git a/.github/workflows/reusable-context.yml b/.github/workflows/reusable-context.yml index cc9841ebf32f27..b8a9e2960eca59 100644 --- a/.github/workflows/reusable-context.yml +++ b/.github/workflows/reusable-context.yml @@ -54,7 +54,8 @@ on: # yamllint disable-line rule:truthy description: Whether to run the Windows tests value: ${{ jobs.compute-changes.outputs.run-windows-tests }} # bool -permissions: {} +permissions: + contents: read jobs: compute-changes: diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 3d534feb2ed3ea..0453b6ab555048 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -4,7 +4,8 @@ on: workflow_call: workflow_dispatch: -permissions: {} +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/reusable-emscripten.yml b/.github/workflows/reusable-emscripten.yml index 300731deb78959..69a780a9aebc25 100644 --- a/.github/workflows/reusable-emscripten.yml +++ b/.github/workflows/reusable-emscripten.yml @@ -3,7 +3,8 @@ name: Reusable Emscripten on: workflow_call: -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index a372d5715290db..f10503055b2259 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -12,7 +12,8 @@ on: required: true type: string -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-san.yml b/.github/workflows/reusable-san.yml index 33cfd578d6819a..9d4f412cfcf6f7 100644 --- a/.github/workflows/reusable-san.yml +++ b/.github/workflows/reusable-san.yml @@ -12,7 +12,8 @@ on: type: boolean default: false -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 @@ -61,7 +62,7 @@ jobs: || '' }}.txt handle_segv=0" >> "$GITHUB_ENV" else - echo "UBSAN_OPTIONS=${SAN_LOG_OPTION}" >> "$GITHUB_ENV" + echo "UBSAN_OPTIONS=${SAN_LOG_OPTION} halt_on_error=1 suppressions=${GITHUB_WORKSPACE}/Tools/ubsan/suppressions.txt" >> "$GITHUB_ENV" fi echo "CC=clang" >> "$GITHUB_ENV" echo "CXX=clang++" >> "$GITHUB_ENV" @@ -75,7 +76,7 @@ jobs: ${{ inputs.sanitizer == 'TSan' && '--with-thread-sanitizer' - || '--with-undefined-behavior-sanitizer' + || '--with-undefined-behavior-sanitizer --with-strict-overflow' }} --with-pydebug ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} @@ -83,10 +84,13 @@ jobs: run: make -j4 - name: Display build info run: make pythoninfo + # test_{capi,faulthandler} are skipped under UBSan because + # they raise signals that UBSan with halt_on_error=1 intercepts. - name: Tests run: >- ./python -m test ${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }} + ${{ inputs.sanitizer == 'UBSan' && '-x test_capi -x test_faulthandler' || '' }} -j4 - name: Parallel tests if: >- diff --git a/.github/workflows/reusable-ubuntu.yml b/.github/workflows/reusable-ubuntu.yml index b2ab525c976330..87fba6221fb917 100644 --- a/.github/workflows/reusable-ubuntu.yml +++ b/.github/workflows/reusable-ubuntu.yml @@ -23,7 +23,8 @@ on: type: string default: '' -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index 83f9d2399ce100..48fb70cbff8009 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -3,7 +3,8 @@ name: Reusable WASI on: workflow_call: -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-windows-msi.yml b/.github/workflows/reusable-windows-msi.yml index 7c724f184f3ef6..a74724323ec15f 100644 --- a/.github/workflows/reusable-windows-msi.yml +++ b/.github/workflows/reusable-windows-msi.yml @@ -8,7 +8,8 @@ on: required: true type: string -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/reusable-windows.yml b/.github/workflows/reusable-windows.yml index 2cfe338a6525e6..4c8d0c8a2f984f 100644 --- a/.github/workflows/reusable-windows.yml +++ b/.github/workflows/reusable-windows.yml @@ -17,7 +17,8 @@ on: required: true type: string -permissions: {} +permissions: + contents: read env: FORCE_COLOR: 1 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index a862fde5e14eb4..01fe5ba8fda8bc 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -4,7 +4,8 @@ on: schedule: - cron: "0 */6 * * *" -permissions: {} +permissions: + contents: read jobs: stale: diff --git a/.github/workflows/tail-call.yml b/.github/workflows/tail-call.yml index 35c62acb28b761..656a14906b3cb7 100644 --- a/.github/workflows/tail-call.yml +++ b/.github/workflows/tail-call.yml @@ -11,7 +11,8 @@ on: paths: *paths workflow_dispatch: -permissions: {} +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/verify-ensurepip-wheels.yml b/.github/workflows/verify-ensurepip-wheels.yml index 4ac25bc909b13f..cb40f6abc0b3b7 100644 --- a/.github/workflows/verify-ensurepip-wheels.yml +++ b/.github/workflows/verify-ensurepip-wheels.yml @@ -13,7 +13,8 @@ on: - '.github/workflows/verify-ensurepip-wheels.yml' - 'Tools/build/verify_ensurepip_wheels.py' -permissions: {} +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/verify-expat.yml b/.github/workflows/verify-expat.yml index e193dfa4603e8a..472a11db2da5fb 100644 --- a/.github/workflows/verify-expat.yml +++ b/.github/workflows/verify-expat.yml @@ -11,7 +11,8 @@ on: - 'Modules/expat/**' - '.github/workflows/verify-expat.yml' -permissions: {} +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e612ce232fb29..6878a7d92e3bee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: a27a2e47c7751b639d2b5badf0ef6ff11fee893f # frozen: v0.15.4 + rev: e05c5c0818279e5ac248ac9e954431ba58865e61 # frozen: v0.15.7 hooks: - id: ruff-check name: Run Ruff (lint) on Platforms/Apple/ @@ -85,6 +85,9 @@ repos: exclude: Lib/test/tokenizedata/coding20731.py - id: end-of-file-fixer files: '^\.github/CODEOWNERS$' + - id: mixed-line-ending + args: [--fix=auto] + exclude: '^Lib/test/.*data/' - id: trailing-whitespace types_or: [c, inc, python, rst, yaml] - id: trailing-whitespace diff --git a/Android/android.py b/Android/android.py index adcc7c708d95f7..9d452ea87fced9 100755 --- a/Android/android.py +++ b/Android/android.py @@ -393,17 +393,6 @@ def setup_testbed(): os.chmod(out_path, 0o755) -# run_testbed will build the app automatically, but it's useful to have this as -# a separate command to allow running the app outside of this script. -def build_testbed(context): - setup_sdk() - setup_testbed() - run( - [gradlew, "--console", "plain", "packageDebug", "packageDebugAndroidTest"], - cwd=TESTBED_DIR, - ) - - # Work around a bug involving sys.exit and TaskGroups # (https://github.com/python/cpython/issues/101515). def exit(*args): @@ -645,6 +634,10 @@ async def gradle_task(context): task_prefix = "connected" env["ANDROID_SERIAL"] = context.connected + # Ensure that CROSS_BUILD_DIR is in the Gradle environment, regardless + # of whether it was set by environment variable or `--cross-build-dir`. + env["CROSS_BUILD_DIR"] = CROSS_BUILD_DIR + if context.ci_mode: context.args[0:0] = [ # See _add_ci_python_opts in libregrtest/main.py. @@ -872,6 +865,18 @@ def parse_args(): def add_parser(*args, **kwargs): parser = subcommands.add_parser(*args, **kwargs) + parser.add_argument( + "--cross-build-dir", + action="store", + default=os.environ.get("CROSS_BUILD_DIR"), + dest="cross_build_dir", + type=Path, + help=( + "Path to the cross-build directory " + f"(default: {CROSS_BUILD_DIR}). Can also be set " + "with the CROSS_BUILD_DIR environment variable." + ), + ) parser.add_argument( "-v", "--verbose", action="count", default=0, help="Show verbose output. Use twice to be even more verbose.") @@ -884,7 +889,7 @@ def add_parser(*args, **kwargs): ) configure_build = add_parser( "configure-build", help="Run `configure` for the build Python") - make_build = add_parser( + add_parser( "make-build", help="Run `make` for the build Python") configure_host = add_parser( "configure-host", help="Run `configure` for Android") @@ -896,38 +901,12 @@ def add_parser(*args, **kwargs): help="Delete build directories for the selected target" ) - add_parser("build-testbed", help="Build the testbed app") test = add_parser("test", help="Run the testbed app") package = add_parser("package", help="Make a release package") ci = add_parser("ci", help="Run build, package and test") env = add_parser("env", help="Print environment variables") # Common arguments - # --cross-build-dir argument - for cmd in [ - clean, - configure_build, - make_build, - configure_host, - make_host, - build, - package, - test, - ci, - ]: - cmd.add_argument( - "--cross-build-dir", - action="store", - default=os.environ.get("CROSS_BUILD_DIR"), - dest="cross_build_dir", - type=Path, - help=( - "Path to the cross-build directory " - f"(default: {CROSS_BUILD_DIR}). Can also be set " - "with the CROSS_BUILD_DIR environment variable." - ), - ) - # --cache-dir option for cmd in [configure_host, build, ci]: cmd.add_argument( @@ -1032,7 +1011,6 @@ def main(): "make-host": make_host_python, "build": build_targets, "clean": clean_targets, - "build-testbed": build_testbed, "test": run_testbed, "package": package, "ci": ci, diff --git a/Android/testbed/app/build.gradle.kts b/Android/testbed/app/build.gradle.kts index b58edc04a929d9..bd8334b64bb0a8 100644 --- a/Android/testbed/app/build.gradle.kts +++ b/Android/testbed/app/build.gradle.kts @@ -8,7 +8,7 @@ plugins { val ANDROID_DIR = file("../..") val PYTHON_DIR = ANDROID_DIR.parentFile!! -val PYTHON_CROSS_DIR = file("$PYTHON_DIR/cross-build") +val PYTHON_CROSS_DIR = file(System.getenv("CROSS_BUILD_DIR") ?: "$PYTHON_DIR/cross-build") val inSourceTree = ( ANDROID_DIR.name == "Android" && file("$PYTHON_DIR/pyconfig.h.in").exists() ) diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst index f44c18e80758bb..a2a0d0d80657eb 100644 --- a/Doc/c-api/dict.rst +++ b/Doc/c-api/dict.rst @@ -45,7 +45,7 @@ Dictionary objects The first argument can be a :class:`dict`, a :class:`frozendict`, or a mapping. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -76,7 +76,12 @@ Dictionary objects The first argument can be a :class:`dict` or a :class:`frozendict`. - .. versionchanged:: next + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -90,7 +95,7 @@ Dictionary objects .. versionadded:: 3.13 - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -105,6 +110,11 @@ Dictionary objects ``0`` on success or ``-1`` on failure. This function *does not* steal a reference to *val*. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. c:function:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val) @@ -120,6 +130,11 @@ Dictionary objects If *key* is not in the dictionary, :exc:`KeyError` is raised. Return ``0`` on success or ``-1`` on failure. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. c:function:: int PyDict_DelItemString(PyObject *p, const char *key) @@ -140,9 +155,14 @@ Dictionary objects The first argument can be a :class:`dict` or a :class:`frozendict`. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. versionadded:: 3.13 - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. See also the :c:func:`PyObject_GetItem` function. @@ -162,11 +182,18 @@ Dictionary objects :meth:`~object.__eq__` methods are silently ignored. Prefer the :c:func:`PyDict_GetItemWithError` function instead. + .. note:: + + In the :term:`free-threaded build`, the returned + :term:`borrowed reference` may become invalid if another thread modifies + the dictionary concurrently. Prefer :c:func:`PyDict_GetItemRef`, which + returns a :term:`strong reference`. + .. versionchanged:: 3.10 Calling this API without an :term:`attached thread state` had been allowed for historical reason. It is no longer allowed. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -177,7 +204,14 @@ Dictionary objects occurred. Return ``NULL`` **without** an exception set if the key wasn't present. - .. versionchanged:: next + .. note:: + + In the :term:`free-threaded build`, the returned + :term:`borrowed reference` may become invalid if another thread modifies + the dictionary concurrently. Prefer :c:func:`PyDict_GetItemRef`, which + returns a :term:`strong reference`. + + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -195,7 +229,14 @@ Dictionary objects Prefer using the :c:func:`PyDict_GetItemWithError` function with your own :c:func:`PyUnicode_FromString` *key* instead. - .. versionchanged:: next + .. note:: + + In the :term:`free-threaded build`, the returned + :term:`borrowed reference` may become invalid if another thread modifies + the dictionary concurrently. Prefer :c:func:`PyDict_GetItemStringRef`, + which returns a :term:`strong reference`. + + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -207,7 +248,7 @@ Dictionary objects .. versionadded:: 3.13 - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -221,6 +262,14 @@ Dictionary objects .. versionadded:: 3.4 + .. note:: + + In the :term:`free-threaded build`, the returned + :term:`borrowed reference` may become invalid if another thread modifies + the dictionary concurrently. Prefer :c:func:`PyDict_SetDefaultRef`, + which returns a :term:`strong reference`. + + .. c:function:: int PyDict_SetDefaultRef(PyObject *p, PyObject *key, PyObject *default_value, PyObject **result) @@ -240,6 +289,11 @@ Dictionary objects These may refer to the same object: in that case you hold two separate references to it. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. versionadded:: 3.13 @@ -257,6 +311,11 @@ Dictionary objects Similar to :meth:`dict.pop`, but without the default value and not raising :exc:`KeyError` if the key is missing. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. versionadded:: 3.13 @@ -275,7 +334,7 @@ Dictionary objects The first argument can be a :class:`dict` or a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -285,7 +344,7 @@ Dictionary objects The first argument can be a :class:`dict` or a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -296,7 +355,7 @@ Dictionary objects The first argument can be a :class:`dict` or a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -309,7 +368,7 @@ Dictionary objects The argument can be a :class:`dict` or a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -317,7 +376,7 @@ Dictionary objects Similar to :c:func:`PyDict_Size`, but without error checking. - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. @@ -391,7 +450,7 @@ Dictionary objects :term:`strong reference ` (for example, using :c:func:`Py_NewRef`). - .. versionchanged:: next + .. versionchanged:: 3.15 Also accept :class:`frozendict`. .. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override) @@ -403,6 +462,13 @@ Dictionary objects only be added if there is not a matching key in *a*. Return ``0`` on success or ``-1`` if an exception was raised. + .. note:: + + In the :term:`free-threaded build`, when *b* is a + :class:`dict` (with the standard iterator), both *a* and *b* are locked + for the duration of the operation. When *b* is a non-dict mapping, only + *a* is locked; *b* may be concurrently modified by another thread. + .. c:function:: int PyDict_Update(PyObject *a, PyObject *b) @@ -412,6 +478,13 @@ Dictionary objects argument has no "keys" attribute. Return ``0`` on success or ``-1`` if an exception was raised. + .. note:: + + In the :term:`free-threaded build`, when *b* is a + :class:`dict` (with the standard iterator), both *a* and *b* are locked + for the duration of the operation. When *b* is a non-dict mapping, only + *a* is locked; *b* may be concurrently modified by another thread. + .. c:function:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override) @@ -427,6 +500,13 @@ Dictionary objects if override or key not in a: a[key] = value + .. note:: + + In the :term:`free-threaded ` build, only *a* is locked. + The iteration over *seq2* is not synchronized; *seq2* may be concurrently + modified by another thread. + + .. c:function:: int PyDict_AddWatcher(PyDict_WatchCallback callback) Register *callback* as a dictionary watcher. Return a non-negative integer @@ -434,6 +514,13 @@ Dictionary objects of error (e.g. no more watcher IDs available), return ``-1`` and set an exception. + .. note:: + + This function is not internally synchronized. In the + :term:`free-threaded ` build, callers should ensure no + concurrent calls to :c:func:`PyDict_AddWatcher` or + :c:func:`PyDict_ClearWatcher` are in progress. + .. versionadded:: 3.12 .. c:function:: int PyDict_ClearWatcher(int watcher_id) @@ -442,6 +529,13 @@ Dictionary objects :c:func:`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the given *watcher_id* was never registered.) + .. note:: + + This function is not internally synchronized. In the + :term:`free-threaded ` build, callers should ensure no + concurrent calls to :c:func:`PyDict_AddWatcher` or + :c:func:`PyDict_ClearWatcher` are in progress. + .. versionadded:: 3.12 .. c:function:: int PyDict_Watch(int watcher_id, PyObject *dict) diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index fed795b1e8c963..9c9c97f7b853d8 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -220,54 +220,237 @@ The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function parameter o detection; it's not expected that users will need to write their own visitor functions. -The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type: +The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or ``NULL`` +if the object is immutable. + + +.. c:type:: int (*inquiry)(PyObject *self) + + Drop references that may have created reference cycles. Immutable objects + do not have to define this method since they can never directly create + reference cycles. Note that the object must still be valid after calling + this method (don't just call :c:func:`Py_DECREF` on a reference). The + collector will call this method if it detects that this object is involved + in a reference cycle. + + +.. _gc-traversal: +Traversal +--------- + +The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type: .. c:type:: int (*traverseproc)(PyObject *self, visitproc visit, void *arg) - Traversal function for a container object. Implementations must call the + Traversal function for a garbage-collected object, used by the garbage + collector to detect reference cycles. + Implementations must call the *visit* function for each object directly contained by *self*, with the parameters to *visit* being the contained object and the *arg* value passed to the handler. The *visit* function must not be called with a ``NULL`` - object argument. If *visit* returns a non-zero value that value should be + object argument. If *visit* returns a non-zero value, that value should be returned immediately. - The traversal function must not have any side effects. Implementations - may not modify the reference counts of any Python objects nor create or - destroy any Python objects. + A typical :c:member:`!tp_traverse` function calls the :c:func:`Py_VISIT` + convenience macro on each of the instance's members that are Python + objects that the instance owns. + For example, this is a (slightly outdated) traversal function for + the :py:class:`threading.local` class:: + + static int + local_traverse(PyObject *op, visitproc visit, void *arg) + { + localobject *self = (localobject *) op; + Py_VISIT(Py_TYPE(self)); + Py_VISIT(self->args); + Py_VISIT(self->kw); + Py_VISIT(self->dict); + return 0; + } + + .. note:: + :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to + :c:func:`!local_traverse` to have these specific names; don't name them just + anything. + + Instances of :ref:`heap-allocated types ` hold a reference to + their type. Their traversal function must therefore visit the type:: + + Py_VISIT(Py_TYPE(self)); + + Alternately, the type may delegate this responsibility by + calling ``tp_traverse`` of a heap-allocated superclass (or another + heap-allocated type, if applicable). + If they do not, the type object may not be garbage-collected. + + If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the + :c:member:`~PyTypeObject.tp_flags` field, the traverse function must call + :c:func:`PyObject_VisitManagedDict` like this:: + + int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg); + if (err) { + return err; + } + + Only the members that the instance *owns* (by having + :term:`strong references ` to them) must be + visited. For instance, if an object supports weak references via the + :c:member:`~PyTypeObject.tp_weaklist` slot, the pointer supporting + the linked list (what *tp_weaklist* points to) must **not** be + visited as the instance does not directly own the weak references to itself. + + The traversal function has a limitation: + + .. warning:: + + The traversal function must not have any side effects. Implementations + may not modify the reference counts of any Python objects nor create or + destroy any Python objects, directly or indirectly. + + This means that *most* Python C API functions may not be used, since + they can raise a new exception, return a new reference to a result object, + have internal logic that uses side effects. + Also, unless documented otherwise, functions that happen to not have side + effects may start having them in future versions, without warning. + + For a list of safe functions, see a + :ref:`separate section ` below. + + .. note:: + + The :c:func:`Py_VISIT` call may be skipped for those members that provably + cannot participate in reference cycles. + In the ``local_traverse`` example above, there is also a ``self->key`` + member, but it can only be ``NULL`` or a Python string and therefore + cannot be part of a reference cycle. + + On the other hand, even if you know a member can never be part of a cycle, + as a debugging aid you may want to visit it anyway just so the :mod:`gc` + module's :func:`~gc.get_referents` function will include it. + + .. note:: + + The :c:member:`~PyTypeObject.tp_traverse` function can be called from any + thread. -To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is -provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation -must name its arguments exactly *visit* and *arg*: + .. impl-detail:: + Garbage collection is a "stop-the-world" operation: + even in :term:`free threading` builds, only one thread state is + :term:`attached ` when :c:member:`!tp_traverse` + handlers run. + + .. versionchanged:: 3.9 + + Heap-allocated types are expected to visit ``Py_TYPE(self)`` in + ``tp_traverse``. In earlier versions of Python, due to + `bug 40217 `_, doing this + may lead to crashes in subclasses. + +To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, +a :c:func:`Py_VISIT` macro is provided. +In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` +implementation must name its arguments exactly *visit* and *arg*: .. c:macro:: Py_VISIT(o) - If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, with arguments *o* - and *arg*. If *visit* returns a non-zero value, then return it. - Using this macro, :c:member:`~PyTypeObject.tp_traverse` handlers - look like:: + If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* + callback, with arguments *o* and *arg*. + If *visit* returns a non-zero value, then return it. - static int - my_traverse(Noddy *self, visitproc visit, void *arg) - { - Py_VISIT(self->foo); - Py_VISIT(self->bar); - return 0; - } + This corresponds roughly to:: -The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:`inquiry` type, or ``NULL`` -if the object is immutable. + #define Py_VISIT(o) \ + if (op) { \ + int visit_result = visit(o, arg); \ + if (visit_result != 0) { \ + return visit_result; \ + } \ + } -.. c:type:: int (*inquiry)(PyObject *self) +Traversal-safe functions +^^^^^^^^^^^^^^^^^^^^^^^^ - Drop references that may have created reference cycles. Immutable objects - do not have to define this method since they can never directly create - reference cycles. Note that the object must still be valid after calling - this method (don't just call :c:func:`Py_DECREF` on a reference). The - collector will call this method if it detects that this object is involved - in a reference cycle. +The following functions and macros are safe to use in a +:c:member:`~PyTypeObject.tp_traverse` handler: + +* the *visit* function passed to ``tp_traverse`` +* :c:func:`Py_VISIT` +* :c:func:`Py_SIZE` +* :c:func:`Py_TYPE`: if called from a :c:member:`!tp_traverse` handler, + :c:func:`!Py_TYPE`'s result will be valid for the duration of the handler call +* :c:func:`PyObject_VisitManagedDict` +* :c:func:`PyObject_TypeCheck`, :c:func:`PyType_IsSubtype`, + :c:func:`PyType_HasFeature` +* :samp:`Py{}_Check` and :samp:`Py{}_CheckExact` -- for example, + :c:func:`PyTuple_Check` +* :ref:`duringgc-functions` + +.. _duringgc-functions: + +"DuringGC" functions +^^^^^^^^^^^^^^^^^^^^ + +The following functions should *only* be used in a +:c:member:`~PyTypeObject.tp_traverse` handler; calling them in other +contexts may have unintended consequences. + +These functions act like their counterparts without the ``_DuringGC`` suffix, +but they are guaranteed to not have side effects, they do not set an exception +on failure, and they return/set :term:`borrowed references ` +as detailed in the individual documentation. + +Note that these functions may fail (return ``NULL`` or ``-1``), +but as they do not set an exception, no error information is available. +In some cases, failure is not distinguishable from a successful ``NULL`` result. + +.. c:function:: void *PyObject_GetTypeData_DuringGC(PyObject *o, PyTypeObject *cls) + void *PyObject_GetItemData_DuringGC(PyObject *o) + void *PyType_GetModuleState_DuringGC(PyTypeObject *type) + void *PyModule_GetState_DuringGC(PyObject *module) + int PyModule_GetToken_DuringGC(PyObject *module, void** result) + + See :ref:`duringgc-functions` for common information. + + .. versionadded:: next + + .. seealso:: + + :c:func:`PyObject_GetTypeData`, + :c:func:`PyObject_GetItemData`, + :c:func:`PyType_GetModuleState`, + :c:func:`PyModule_GetState`, + :c:func:`PyModule_GetToken`, + :c:func:`PyType_GetBaseByToken` + +.. c:function:: int PyType_GetBaseByToken_DuringGC(PyTypeObject *type, void *tp_token, PyTypeObject **result) + + See :ref:`duringgc-functions` for common information. + + Sets *\*result* to a :term:`borrowed reference` rather than a strong one. + The reference is valid for the duration + of the :c:member:`!tp_traverse` handler call. + + .. versionadded:: next + + .. seealso:: :c:func:`PyType_GetBaseByToken` + +.. c:function:: PyObject* PyType_GetModule_DuringGC(PyTypeObject *type) + PyObject* PyType_GetModuleByToken_DuringGC(PyTypeObject *type, const void *mod_token) + + See :ref:`duringgc-functions` for common information. + + These functions return a :term:`borrowed reference`, which is + valid for the duration of the :c:member:`!tp_traverse` handler call. + + .. versionadded:: next + + .. seealso:: + + :c:func:`PyType_GetModule`, + :c:func:`PyType_GetModuleByToken` Controlling the Garbage Collector State diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst index f6dc604a609cb1..209e48767ccfd6 100644 --- a/Doc/c-api/init_config.rst +++ b/Doc/c-api/init_config.rst @@ -1807,10 +1807,10 @@ PyConfig .. c:member:: wchar_t* run_presite - ``package.module`` path to module that should be imported before - ``site.py`` is run. + ``module`` or ``module:func`` entry point that should be executed before + the :mod:`site` module is imported. - Set by the :option:`-X presite=package.module <-X>` command-line + Set by the :option:`-X presite=module:func <-X>` command-line option and the :envvar:`PYTHON_PRESITE` environment variable. The command-line option takes precedence. diff --git a/Doc/c-api/interp-lifecycle.rst b/Doc/c-api/interp-lifecycle.rst index 189d8e424f6814..186ab4370bcb9c 100644 --- a/Doc/c-api/interp-lifecycle.rst +++ b/Doc/c-api/interp-lifecycle.rst @@ -410,6 +410,11 @@ Initializing and finalizing the interpreter (zero) if not. After :c:func:`Py_FinalizeEx` is called, this returns false until :c:func:`Py_Initialize` is called again. + .. versionchanged:: next + This function no longer returns true until initialization has fully + completed, including import of the :mod:`site` module. Previously it + could return true while :c:func:`Py_Initialize` was still running. + .. c:function:: int Py_IsFinalizing() diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index e42c1dbf420069..2a22a023bdafb4 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -536,7 +536,7 @@ have been standardized in C11 (or previous standards). Use the standard ``alignas`` specifier rather than this macro. - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. .. c:macro:: PY_FORMAT_SIZE_T @@ -544,7 +544,7 @@ have been standardized in C11 (or previous standards). The :c:func:`printf` formatting modifier for :c:type:`size_t`. Use ``"z"`` directly instead. - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. .. c:macro:: Py_LL(number) @@ -558,7 +558,7 @@ have been standardized in C11 (or previous standards). Consider using the C99 standard suffixes ``LL`` and ``LLU`` directly. - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. .. c:macro:: PY_LONG_LONG @@ -572,7 +572,7 @@ have been standardized in C11 (or previous standards). respectively. Historically, these types needed compiler-specific extensions. - .. deprecated:: next + .. deprecated:: 3.15 These macros are :term:`soft deprecated`. .. c:macro:: PY_LLONG_MIN @@ -587,7 +587,7 @@ have been standardized in C11 (or previous standards). The required header, ````, :ref:`is included ` in ``Python.h``. - .. deprecated:: next + .. deprecated:: 3.15 These macros are :term:`soft deprecated`. .. c:macro:: Py_MEMCPY(dest, src, n) @@ -606,7 +606,7 @@ have been standardized in C11 (or previous standards). The required header for the latter, ````, :ref:`is included ` in ``Python.h``. - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. .. c:macro:: Py_UNICODE_WIDE @@ -614,7 +614,7 @@ have been standardized in C11 (or previous standards). Defined if ``wchar_t`` can hold a Unicode character (UCS-4). Use ``sizeof(wchar_t) >= 4`` instead - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. .. c:macro:: Py_VA_COPY @@ -627,7 +627,7 @@ have been standardized in C11 (or previous standards). .. versionchanged:: 3.6 This is now an alias to ``va_copy``. - .. deprecated:: next + .. deprecated:: 3.15 The macro is :term:`soft deprecated`. diff --git a/Doc/c-api/set.rst b/Doc/c-api/set.rst index 6974f74fbd597a..53febd0c4c116c 100644 --- a/Doc/c-api/set.rst +++ b/Doc/c-api/set.rst @@ -89,6 +89,11 @@ the constructor functions work with any iterable Python object. actually iterable. The constructor is also useful for copying a set (``c=set(s)``). + .. note:: + + The operation is atomic on :term:`free threading ` + when *iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:`frozendict`. + .. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable) @@ -97,6 +102,11 @@ the constructor functions work with any iterable Python object. set on success or ``NULL`` on failure. Raise :exc:`TypeError` if *iterable* is not actually iterable. + .. note:: + + The operation is atomic on :term:`free threading ` + when *iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:`frozendict`. + The following functions and macros are available for instances of :class:`set` or :class:`frozenset` or instances of their subtypes. @@ -124,6 +134,10 @@ or :class:`frozenset` or instances of their subtypes. the *key* is unhashable. Raise :exc:`SystemError` if *anyset* is not a :class:`set`, :class:`frozenset`, or an instance of a subtype. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. .. c:function:: int PySet_Add(PyObject *set, PyObject *key) @@ -135,6 +149,12 @@ or :class:`frozenset` or instances of their subtypes. :exc:`SystemError` if *set* is not an instance of :class:`set` or its subtype. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + + The following functions are available for instances of :class:`set` or its subtypes but not for instances of :class:`frozenset` or its subtypes. @@ -149,6 +169,11 @@ subtypes but not for instances of :class:`frozenset` or its subtypes. temporary frozensets. Raise :exc:`SystemError` if *set* is not an instance of :class:`set` or its subtype. + .. note:: + + The operation is atomic on :term:`free threading ` + when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`. + .. c:function:: PyObject* PySet_Pop(PyObject *set) @@ -164,6 +189,12 @@ subtypes but not for instances of :class:`frozenset` or its subtypes. success. Return ``-1`` and raise :exc:`SystemError` if *set* is not an instance of :class:`set` or its subtype. + .. note:: + + In the :term:`free-threaded build`, the set is emptied before its entries + are cleared, so other threads will observe an empty set rather than + intermediate states. + Deprecated API ^^^^^^^^^^^^^^ diff --git a/Doc/c-api/stable.rst b/Doc/c-api/stable.rst index f8b41f6d87f975..fe2cb89f999a84 100644 --- a/Doc/c-api/stable.rst +++ b/Doc/c-api/stable.rst @@ -96,7 +96,7 @@ Contents of the Limited API are :ref:`listed below `. .. seealso:: :pep:`803` - .. versionadded:: next + .. versionadded:: 3.15 .. _stable-abi: diff --git a/Doc/c-api/synchronization.rst b/Doc/c-api/synchronization.rst index 53c9faeae35464..a35df60b383a85 100644 --- a/Doc/c-api/synchronization.rst +++ b/Doc/c-api/synchronization.rst @@ -84,11 +84,6 @@ there is no :c:type:`PyObject` -- for example, when working with a C type that does not extend or wrap :c:type:`PyObject` but still needs to call into the C API in a manner that might lead to deadlocks. -The functions and structs used by the macros are exposed for cases -where C macros are not available. They should only be used as in the -given macro expansions. Note that the sizes and contents of the structures may -change in future Python versions. - .. note:: Operations that need to lock two objects at once must use @@ -114,12 +109,15 @@ section API avoids potential deadlocks due to reentrancy and lock ordering by allowing the runtime to temporarily suspend the critical section if the code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`. +.. _critical-section-macros: + .. c:macro:: Py_BEGIN_CRITICAL_SECTION(op) Acquires the per-object lock for the object *op* and begins a critical section. - In the free-threaded build, this macro expands to:: + In the free-threaded build, and when building for the + :ref:`Stable ABI `, this macro expands to:: { PyCriticalSection _py_cs; @@ -150,7 +148,8 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`. Ends the critical section and releases the per-object lock. - In the free-threaded build, this macro expands to:: + In the free-threaded build, and when building for the + :ref:`Stable ABI `, this macro expands to:: PyCriticalSection_End(&_py_cs); } @@ -179,7 +178,8 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`. Locks the mutexes *m1* and *m2* and begins a critical section. - In the free-threaded build, this macro expands to:: + In the free-threaded build, and when building for the + :ref:`Stable ABI `, this macro expands to:: { PyCriticalSection2 _py_cs2; @@ -196,7 +196,8 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`. Ends the critical section and releases the per-object locks. - In the free-threaded build, this macro expands to:: + In the free-threaded build, and when building for the + :ref:`Stable ABI `, this macro expands to:: PyCriticalSection2_End(&_py_cs2); } @@ -205,6 +206,42 @@ code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`. .. versionadded:: 3.13 +Low-level critical section API +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following functions and structs are exposed for cases where C macros +are not available. + +.. c:function:: void PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op) + void PyCriticalSection_End(PyCriticalSection *c) + void PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b) + void PyCriticalSection2_End(PyCriticalSection2 *c); + + To be used only as in the macro expansions + listed :ref:`earlier in this section `. + + .. versionadded:: 3.13 + +.. c:type:: PyCriticalSection + PyCriticalSection2 + + To be used only as in the macro expansions + listed :ref:`earlier in this section `. + Note that the contents of the structures are private and their meaning may + change in future Python versions. + + .. versionadded:: 3.13 + +.. c:function:: void PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m); + void PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2); + + .. These need to be in a separate section without a Stable ABI anotation. + + To be used only as in the macro expansions + listed :ref:`earlier in this section `. + + .. versionadded:: 3.14 + Legacy locking APIs ------------------- diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index 3e3752696c46d8..ba4c6b93de4c11 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -99,7 +99,8 @@ Tuple Objects Insert a reference to object *o* at position *pos* of the tuple pointed to by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` - and set an :exc:`IndexError` exception. + and set an :exc:`IndexError` exception. This function should only be used to fill in brand new tuples; + using it on an existing tuple is thread-unsafe. .. note:: @@ -110,7 +111,7 @@ Tuple Objects .. c:function:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o) Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be - used to fill in brand new tuples. + used to fill in brand new tuples, using it on an existing tuple is thread-unsafe. Bounds checking is performed as an assertion if Python is built in :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. @@ -236,6 +237,8 @@ type. .. c:function:: PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos) Return the object at position *pos* in the struct sequence pointed to by *p*. + The returned reference is borrowed from the struct sequence *p* + (that is: it is only valid as long as you hold a reference to *p*). Bounds checking is performed as an assertion if Python is built in :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index cd13c0f4d61a42..c3960d6ff87ec8 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -1563,93 +1563,9 @@ and :c:data:`PyType_Type` effectively act as defaults.) .. corresponding-type-slot:: Py_tp_traverse An optional pointer to a traversal function for the garbage collector. This is - only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The signature is:: + only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. - int tp_traverse(PyObject *self, visitproc visit, void *arg); - - More information about Python's garbage collection scheme can be found - in section :ref:`supporting-cycle-detection`. - - The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect - reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function - simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python - objects that the instance owns. For example, this is function :c:func:`!local_traverse` from the - :mod:`!_thread` extension module:: - - static int - local_traverse(PyObject *op, visitproc visit, void *arg) - { - localobject *self = (localobject *) op; - Py_VISIT(self->args); - Py_VISIT(self->kw); - Py_VISIT(self->dict); - return 0; - } - - Note that :c:func:`Py_VISIT` is called only on those members that can participate - in reference cycles. Although there is also a ``self->key`` member, it can only - be ``NULL`` or a Python string and therefore cannot be part of a reference cycle. - - On the other hand, even if you know a member can never be part of a cycle, as a - debugging aid you may want to visit it anyway just so the :mod:`gc` module's - :func:`~gc.get_referents` function will include it. - - Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with:: - - Py_VISIT(Py_TYPE(self)); - - It is only needed since Python 3.9. To support Python 3.8 and older, this - line must be conditional:: - - #if PY_VERSION_HEX >= 0x03090000 - Py_VISIT(Py_TYPE(self)); - #endif - - If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the - :c:member:`~PyTypeObject.tp_flags` field, the traverse function must call - :c:func:`PyObject_VisitManagedDict` like this:: - - PyObject_VisitManagedDict((PyObject*)self, visit, arg); - - .. warning:: - When implementing :c:member:`~PyTypeObject.tp_traverse`, only the - members that the instance *owns* (by having :term:`strong references - ` to them) must be - visited. For instance, if an object supports weak references via the - :c:member:`~PyTypeObject.tp_weaklist` slot, the pointer supporting - the linked list (what *tp_weaklist* points to) must **not** be - visited as the instance does not directly own the weak references to itself - (the weakreference list is there to support the weak reference machinery, - but the instance has no strong reference to the elements inside it, as they - are allowed to be removed even if the instance is still alive). - - .. warning:: - The traversal function must not have any side effects. It must not - modify the reference counts of any Python objects nor create or destroy - any Python objects. - - Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to - :c:func:`!local_traverse` to have these specific names; don't name them just - anything. - - Instances of :ref:`heap-allocated types ` hold a reference to - their type. Their traversal function must therefore either visit - :c:func:`Py_TYPE(self) `, or delegate this responsibility by - calling ``tp_traverse`` of another heap-allocated type (such as a - heap-allocated superclass). - If they do not, the type object may not be garbage-collected. - - .. note:: - - The :c:member:`~PyTypeObject.tp_traverse` function can be called from any - thread. - - .. versionchanged:: 3.9 - - Heap-allocated types are expected to visit ``Py_TYPE(self)`` in - ``tp_traverse``. In earlier versions of Python, due to - `bug 40217 `_, doing this - may lead to crashes in subclasses. + See :ref:`gc-traversal` for documentation. **Inheritance:** diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 679823948e73b5..059a7ef399ae0f 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1881,6 +1881,10 @@ object. On success, return ``0``. On error, set an exception, leave the writer unchanged, and return ``-1``. + To write a :class:`str` subclass which overrides the :meth:`~object.__str__` + method, :c:func:`PyUnicode_FromObject` can be used to get the original + string. + .. c:function:: int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj) Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 01b064f3e617ff..2a6e6b963134bb 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2430,10 +2430,17 @@ PyType_GetName:PyTypeObject*:type:0: PyType_GetModule:PyObject*::0: PyType_GetModule:PyTypeObject*:type:0: +PyType_GetModule_DuringGC:PyObject*::0: +PyType_GetModule_DuringGC:PyTypeObject*:type:0: + PyType_GetModuleByToken:PyObject*::+1: PyType_GetModuleByToken:PyTypeObject*:type:0: PyType_GetModuleByToken:PyModuleDef*:def:: +PyType_GetModuleByToken_DuringGC:PyObject*::0: +PyType_GetModuleByToken_DuringGC:PyTypeObject*:type:0: +PyType_GetModuleByToken_DuringGC:PyModuleDef*:mod_token:: + PyType_GetModuleByDef:PyObject*::0: PyType_GetModuleByDef:PyTypeObject*:type:0: PyType_GetModuleByDef:PyModuleDef*:def:: diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat index 510e683c87e8b9..b79a6ad9bcb3ff 100644 --- a/Doc/data/stable_abi.dat +++ b/Doc/data/stable_abi.dat @@ -129,6 +129,12 @@ func,PyComplex_FromDoubles,3.2,, func,PyComplex_ImagAsDouble,3.2,, func,PyComplex_RealAsDouble,3.2,, data,PyComplex_Type,3.2,, +type,PyCriticalSection,3.15,,full-abi +type,PyCriticalSection2,3.15,,full-abi +func,PyCriticalSection2_Begin,3.15,, +func,PyCriticalSection2_End,3.15,, +func,PyCriticalSection_Begin,3.15,, +func,PyCriticalSection_End,3.15,, func,PyDescr_NewClassMethod,3.2,, func,PyDescr_NewGetSet,3.2,, func,PyDescr_NewMember,3.2,, @@ -495,7 +501,9 @@ func,PyModule_GetName,3.2,, func,PyModule_GetNameObject,3.7,, func,PyModule_GetState,3.2,, func,PyModule_GetStateSize,3.15,, +func,PyModule_GetState_DuringGC,3.15,, func,PyModule_GetToken,3.15,, +func,PyModule_GetToken_DuringGC,3.15,, func,PyModule_New,3.2,, func,PyModule_NewObject,3.7,, func,PyModule_SetDocString,3.7,, @@ -598,6 +606,7 @@ func,PyObject_GetIter,3.2,, func,PyObject_GetOptionalAttr,3.13,, func,PyObject_GetOptionalAttrString,3.13,, func,PyObject_GetTypeData,3.12,, +func,PyObject_GetTypeData_DuringGC,3.15,, func,PyObject_HasAttr,3.2,, func,PyObject_HasAttrString,3.2,, func,PyObject_HasAttrStringWithError,3.13,, @@ -750,13 +759,17 @@ func,PyType_FromSpecWithBases,3.3,, func,PyType_GenericAlloc,3.2,, func,PyType_GenericNew,3.2,, func,PyType_GetBaseByToken,3.14,, +func,PyType_GetBaseByToken_DuringGC,3.15,, func,PyType_GetFlags,3.2,, func,PyType_GetFullyQualifiedName,3.13,, func,PyType_GetModule,3.10,, func,PyType_GetModuleByDef,3.13,, func,PyType_GetModuleByToken,3.15,, +func,PyType_GetModuleByToken_DuringGC,3.15,, func,PyType_GetModuleName,3.13,, func,PyType_GetModuleState,3.10,, +func,PyType_GetModuleState_DuringGC,3.15,, +func,PyType_GetModule_DuringGC,3.15,, func,PyType_GetName,3.11,, func,PyType_GetQualName,3.11,, func,PyType_GetSlot,3.4,, @@ -898,6 +911,8 @@ macro,Py_AUDIT_READ,3.12,, func,Py_AddPendingCall,3.2,, func,Py_AtExit,3.2,, macro,Py_BEGIN_ALLOW_THREADS,3.2,, +macro,Py_BEGIN_CRITICAL_SECTION,3.15,, +macro,Py_BEGIN_CRITICAL_SECTION2,3.15,, macro,Py_BLOCK_THREADS,3.2,, func,Py_BuildValue,3.2,, func,Py_BytesMain,3.8,, @@ -905,6 +920,8 @@ func,Py_CompileString,3.2,, func,Py_DecRef,3.2,, func,Py_DecodeLocale,3.7,, macro,Py_END_ALLOW_THREADS,3.2,, +macro,Py_END_CRITICAL_SECTION,3.15,, +macro,Py_END_CRITICAL_SECTION2,3.15,, func,Py_EncodeLocale,3.7,, func,Py_EndInterpreter,3.2,, func,Py_EnterRecursiveCall,3.9,, diff --git a/Doc/data/threadsafety.dat b/Doc/data/threadsafety.dat index 82edd1167ef128..ea5a24a5505e20 100644 --- a/Doc/data/threadsafety.dat +++ b/Doc/data/threadsafety.dat @@ -14,10 +14,71 @@ # The function name must match the C domain identifier used in the documentation. # Synchronization primitives (Doc/c-api/synchronization.rst) -PyMutex_Lock:shared: -PyMutex_Unlock:shared: +PyMutex_Lock:atomic: +PyMutex_Unlock:atomic: PyMutex_IsLocked:atomic: + +# Dictionary objects (Doc/c-api/dict.rst) + +# Type checks - read ob_type pointer, always safe +PyDict_Check:atomic: +PyDict_CheckExact:atomic: + +# Creation - pure allocation, no shared state +PyDict_New:atomic: + +# Lock-free lookups - use _Py_dict_lookup_threadsafe(), no locking. +# Atomic with simple types. +PyDict_Contains:shared: +PyDict_ContainsString:atomic: +PyDict_GetItemRef:shared: +PyDict_GetItemStringRef:atomic: +PyDict_Size:atomic: +PyDict_GET_SIZE:atomic: + +# Borrowed-reference lookups - lock-free dict access but returned +# borrowed reference is unsafe in free-threaded builds without +# external synchronization +PyDict_GetItem:compatible: +PyDict_GetItemWithError:compatible: +PyDict_GetItemString:compatible: +PyDict_SetDefault:compatible: + +# Iteration - no locking; returns borrowed refs +PyDict_Next:compatible: + +# Single-item mutations - protected by per-object critical section +PyDict_SetItem:shared: +PyDict_SetItemString:atomic: +PyDict_DelItem:shared: +PyDict_DelItemString:atomic: +PyDict_SetDefaultRef:shared: +PyDict_Pop:shared: +PyDict_PopString:atomic: + +# Bulk reads - hold per-object lock for duration +PyDict_Clear:atomic: +PyDict_Copy:atomic: +PyDict_Keys:atomic: +PyDict_Values:atomic: +PyDict_Items:atomic: + +# Merge/update - lock target dict; also lock source when it is a dict +PyDict_Update:shared: +PyDict_Merge:shared: +PyDict_MergeFromSeq2:shared: + +# Watcher registration - no synchronization on interpreter state +PyDict_AddWatcher:compatible: +PyDict_ClearWatcher:compatible: + +# Per-dict watcher tags - non-atomic RMW on _ma_watcher_tag; +# safe on distinct dicts only +PyDict_Watch:distinct: +PyDict_Unwatch:distinct: + + # List objects (Doc/c-api/list.rst) # Type checks - read ob_type pointer, always safe @@ -125,6 +186,29 @@ PyByteArray_GET_SIZE:atomic: PyByteArray_AsString:compatible: PyByteArray_AS_STRING:compatible: +# Creation - may iterate the iterable argument, calling arbitrary code. +# Atomic for sets, frozensets, dicts, and frozendicts. +PySet_New:shared: +PyFrozenSet_New:shared: + +# Size - uses atomic load on free-threaded builds +PySet_Size:atomic: +PySet_GET_SIZE:atomic: + +# Contains - lock-free, atomic with simple types +PySet_Contains:shared: + +# Mutations - hold per-object lock for duration +# atomic with simple types +PySet_Add:shared: +PySet_Discard:shared: + +# Pop - hold per-object lock for duration +PySet_Pop:atomic: + +# Clear - empties the set before clearing +PySet_Clear:atomic: + # Capsule objects (Doc/c-api/capsule.rst) # Type check - read ob_type pointer, always safe @@ -153,3 +237,48 @@ PyCapsule_SetContext:distinct: # Import - looks up a capsule from a module attribute and # calls PyCapsule_GetPointer; may call arbitrary code PyCapsule_Import:compatible: + +# Tuple objects + +# Creation - pure allocation, no shared state +PyTuple_New:atomic: +PyTuple_FromArray:atomic: +PyTuple_Pack:atomic: + +# Size - tuples are immutable so size never changes +PyTuple_Size:atomic: +PyTuple_GET_SIZE:atomic: + +# Borrowed-reference lookups - tuples are immutable so items +# never change, however the tuple must be kept alive while using the borrowed reference +PyTuple_GetItem:compatible: +PyTuple_GET_ITEM:compatible: + +# Slice - creates a new tuple from an existing tuple +PyTuple_GetSlice:atomic: + +# SetItem - only usable on tuples with refcount 1 +PyTuple_SetItem:compatible: +PyTuple_SET_ITEM:compatible: + +# Resize - only usable on tuples with refcount 1 +_PyTuple_Resize:compatible: + +# Struct Sequence objects + +# Creation +PyStructSequence_NewType:atomic: +PyStructSequence_New:atomic: + +# Initialization - modifies the type object in place +PyStructSequence_InitType:distinct: +PyStructSequence_InitType2:distinct: + +# Borrowed-reference lookups - same as tuple items +PyStructSequence_GetItem:compatible: +PyStructSequence_GET_ITEM:compatible: + +# SetItem - only for filling in brand new instances +PyStructSequence_SetItem:compatible: +PyStructSequence_SET_ITEM:compatible: + diff --git a/Doc/library/array.rst b/Doc/library/array.rst index 8b0a0c84548127..4468edb6efa654 100644 --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -77,7 +77,7 @@ Notes: as :c:expr:`_Float16` type, if the compiler supports the Annex H of the C23 standard. - .. versionadded:: next + .. versionadded:: 3.15 (4) Complex types (``F`` and ``D``) are available unconditionally, diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst index 4b69e569523c58..43977de273e61f 100644 --- a/Doc/library/asyncio-future.rst +++ b/Doc/library/asyncio-future.rst @@ -196,6 +196,10 @@ Future Object Otherwise, change the Future's state to *cancelled*, schedule the callbacks, and return ``True``. + The optional string argument *msg* is passed as the argument to the + :exc:`CancelledError` exception raised when a cancelled Future + is awaited. + .. versionchanged:: 3.9 Added the *msg* parameter. diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst index 40edd60abead84..5e08d56fd66186 100644 --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -142,7 +142,7 @@ POST request. standard Base64 alphabet, and return the encoded :class:`bytes`. The result can still contain ``=`` if *padded* is true (default). - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *padded* parameter. @@ -154,7 +154,7 @@ POST request. ``/`` in the standard Base64 alphabet, and return the decoded :class:`bytes`. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *padded* parameter. Padding of input is no longer required by default. @@ -175,7 +175,7 @@ POST request. after at most every *wrapcol* characters. If *wrapcol* is zero (default), do not add any newlines. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *padded* and *wrapcol* parameters. @@ -209,7 +209,7 @@ POST request. incorrectly padded or if there are non-alphabet characters present in the input. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* and *padded* parameters. @@ -220,7 +220,7 @@ POST request. .. versionadded:: 3.10 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *padded* and *wrapcol* parameters. @@ -236,7 +236,7 @@ POST request. .. versionadded:: 3.10 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* and *padded* parameters. @@ -249,7 +249,7 @@ POST request. after at most every *wrapcol* characters. If *wrapcol* is zero (default), do not add any newlines. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *wrapcol* parameter. @@ -269,7 +269,7 @@ POST request. incorrectly padded or if there are non-alphabet characters present in the input. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. @@ -351,7 +351,7 @@ Refer to the documentation of the individual functions for more information. .. versionadded:: 3.4 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *wrapcol* parameter. @@ -366,7 +366,7 @@ Refer to the documentation of the individual functions for more information. .. versionadded:: 3.4 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. @@ -388,7 +388,7 @@ Refer to the documentation of the individual functions for more information. .. versionchanged:: 3.15 The *pad* parameter was added. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *wrapcol* parameter. @@ -403,7 +403,7 @@ Refer to the documentation of the individual functions for more information. .. versionadded:: 3.13 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst index de5e5766779baa..08a82cc4b5f6d5 100644 --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -233,7 +233,7 @@ The :mod:`!binascii` module defines the following functions: Invalid base32 data will raise :exc:`binascii.Error`. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: b2a_base32(data, /, *, padded=True, alphabet=BASE32_ALPHABET, wrapcol=0) @@ -251,7 +251,7 @@ The :mod:`!binascii` module defines the following functions: after at most every *wrapcol* characters. If *wrapcol* is zero (default), do not insert any newlines. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: a2b_qp(data, header=False) @@ -341,7 +341,7 @@ The :mod:`!binascii` module defines the following functions: liberal towards whitespace) is also accessible using the :meth:`bytes.fromhex` class method. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. @@ -360,55 +360,55 @@ The :mod:`!binascii` module defines the following functions: The Base 64 alphabet according to :rfc:`4648`. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: URLSAFE_BASE64_ALPHABET The "URL and filename safe" Base 64 alphabet according to :rfc:`4648`. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: UU_ALPHABET The uuencoding alphabet. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: CRYPT_ALPHABET The Base 64 alphabet used in the :manpage:`crypt(3)` routine and in the GEDCOM format. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: BINHEX_ALPHABET The Base 64 alphabet used in BinHex 4 (HQX) within the classic Mac OS. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: BASE85_ALPHABET The Base85 alphabet. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: ASCII85_ALPHABET The Ascii85 alphabet. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: Z85_ALPHABET The `Z85 `_ alphabet. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: BASE32_ALPHABET The Base 32 alphabet according to :rfc:`4648`. - .. versionadded:: next + .. versionadded:: 3.15 .. data:: BASE32HEX_ALPHABET @@ -416,7 +416,7 @@ The :mod:`!binascii` module defines the following functions: Data encoded with this alphabet maintains its sort order during bitwise comparisons. - .. versionadded:: next + .. versionadded:: 3.15 .. seealso:: diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 0b3ad4573f5fcf..571975d4674397 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1756,7 +1756,7 @@ as a default or fallback. (or by) Python. It is recommended to only use this function as a default or fallback, - .. deprecated:: next + .. deprecated:: 3.15 This function is :term:`soft deprecated`. It is kept for use in cases where it works, but not expected to be diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index e8c4605d0578e2..119141d2e6daf3 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -644,7 +644,7 @@ are always available. They are listed here in alphabetical order. If the given source is a string, then leading and trailing spaces and tabs are stripped. - See :func:`ast.literal_eval` for a function that can safely evaluate strings + See :func:`ast.literal_eval` for a function to evaluate strings with expressions containing only literals. .. audit-event:: exec code_object eval diff --git a/Doc/library/getpass.rst b/Doc/library/getpass.rst index a6ca230d5e81a8..fd96f3bbf6a574 100644 --- a/Doc/library/getpass.rst +++ b/Doc/library/getpass.rst @@ -55,7 +55,7 @@ The :mod:`!getpass` module provides two functions: .. versionchanged:: 3.14 Added the *echo_char* parameter for keyboard feedback. - .. versionchanged:: next + .. versionchanged:: 3.15 When using non-empty *echo_char* on Unix, keyboard shortcuts (including cursor movement and line editing) are now properly handled using the terminal's control character configuration. diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index 52c44928153337..b24e4da7bc8c07 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -83,6 +83,11 @@ The :mod:`!glob` module defines the following functions: This function may return duplicate path names if *pathname* contains multiple "``**``" patterns and *recursive* is true. + .. note:: + Any :exc:`OSError` exceptions raised from scanning the filesystem are + suppressed. This includes :exc:`PermissionError` when accessing + directories without read permission. + .. versionchanged:: 3.5 Support for recursive globs using "``**``". @@ -106,6 +111,11 @@ The :mod:`!glob` module defines the following functions: This function may return duplicate path names if *pathname* contains multiple "``**``" patterns and *recursive* is true. + .. note:: + Any :exc:`OSError` exceptions raised from scanning the filesystem are + suppressed. This includes :exc:`PermissionError` when accessing + directories without read permission. + .. versionchanged:: 3.5 Support for recursive globs using "``**``". diff --git a/Doc/library/importlib.metadata.rst b/Doc/library/importlib.metadata.rst index cc426326b29932..63de4f91f4ba5f 100644 --- a/Doc/library/importlib.metadata.rst +++ b/Doc/library/importlib.metadata.rst @@ -18,11 +18,9 @@ the metadata of an installed `Distribution Package `_\s, modules, if any). Built in part on Python's import system, this library -intends to replace similar functionality in the `entry point -API`_ and `metadata API`_ of ``pkg_resources``. Along with -:mod:`importlib.resources`, -this package can eliminate the need to use the older and less efficient -``pkg_resources`` package. +provides the entry point and metadata APIs that were previously +exposed by the now-removed ``pkg_resources`` package. Along with +:mod:`importlib.resources`, it supersedes ``pkg_resources``. ``importlib.metadata`` operates on third-party *distribution packages* installed into Python's ``site-packages`` directory via tools such as @@ -717,7 +715,3 @@ packages served by the ``DatabaseImporter``, assuming that the The ``DatabaseDistribution`` may also provide other metadata files, like ``RECORD`` (required for :attr:`!Distribution.files`) or override the implementation of :attr:`!Distribution.files`. See the source for more inspiration. - - -.. _`entry point API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points -.. _`metadata API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api diff --git a/Doc/library/importlib.resources.rst b/Doc/library/importlib.resources.rst index 20297f9fe307b5..653fa61420be86 100644 --- a/Doc/library/importlib.resources.rst +++ b/Doc/library/importlib.resources.rst @@ -31,15 +31,13 @@ not** have to exist as physical files and directories on the file system: for example, a package and its resources can be imported from a zip file using :py:mod:`zipimport`. -.. note:: +.. warning:: + + :mod:`importlib.resources` follows the same security model as the built-in + :func:`open` function. Passing untrusted inputs to the functions + in this module is unsafe. - This module provides functionality similar to `pkg_resources - `_ `Basic - Resource Access - `_ - without the performance overhead of that package. This makes reading - resources included in packages easier, with more stable and consistent - semantics. +.. note:: The standalone backport of this module provides more information on `using importlib.resources diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 06a71535b5c93c..5a0ac60ab7d2ec 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -850,7 +850,7 @@ and :term:`generators ` which incur interpreter overhead. def running_mean(iterable): "Yield the average of all values seen so far." - # running_mean([8.5, 9.5, 7.5, 6.5]) -> 8.5 9.0 8.5 8.0 + # running_mean([8.5, 9.5, 7.5, 6.5]) → 8.5 9.0 8.5 8.0 return map(truediv, accumulate(iterable), count(1)) def repeatfunc(function, times=None, *args): @@ -932,10 +932,10 @@ and :term:`generators ` which incur interpreter overhead. yield element def unique(iterable, key=None, reverse=False): - "Yield unique elements in sorted order. Supports unhashable inputs." - # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4] - sequenced = sorted(iterable, key=key, reverse=reverse) - return unique_justseen(sequenced, key=key) + "Yield unique elements in sorted order. Supports unhashable inputs." + # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4] + sequenced = sorted(iterable, key=key, reverse=reverse) + return unique_justseen(sequenced, key=key) def sliding_window(iterable, n): "Collect data into overlapping fixed-length chunks or blocks." diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 72632a8ef53d5b..b354e7ba534835 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -358,7 +358,7 @@ Basic Usage conversion length limitation ` to help avoid denial of service attacks. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the optional *array_hook* parameter. .. function:: loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, array_hook=None, **kw) @@ -429,7 +429,7 @@ Encoders and Decoders *array_hook* will be used instead of the :class:`list`. This feature can be used to implement custom decoders. - .. versionchanged:: next + .. versionchanged:: 3.15 Added support for *array_hook*. *parse_float* is an optional function that will be called with the string of diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 2b67d10d7bf1b7..63bc252e129dfb 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -932,7 +932,8 @@ For an example of the usage of queues for interprocess communication see standard library's :mod:`queue` module are raised to signal timeouts. :class:`Queue` implements all the methods of :class:`queue.Queue` except for - :meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`. + :meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and + :meth:`~queue.Queue.shutdown`. .. method:: qsize() diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 2b4aa1ee209997..2867015042ee16 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -1351,6 +1351,11 @@ Reading directories ``False``, this method follows symlinks except when expanding "``**``" wildcards. Set *recurse_symlinks* to ``True`` to always follow symlinks. + .. note:: + Any :exc:`OSError` exceptions raised from scanning the filesystem are + suppressed. This includes :exc:`PermissionError` when accessing + directories without read permission. + .. audit-event:: pathlib.Path.glob self,pattern pathlib.Path.glob .. versionchanged:: 3.12 @@ -1377,6 +1382,11 @@ Reading directories The paths are returned in no particular order. If you need a specific order, sort the results. + .. note:: + Any :exc:`OSError` exceptions raised from scanning the filesystem are + suppressed. This includes :exc:`PermissionError` when accessing + directories without read permission. + .. seealso:: :ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation. diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst index 77ed44c2bb7c0c..4f043fbb3a46df 100644 --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -220,7 +220,7 @@ PrettyPrinter Objects .. versionchanged:: 3.11 No longer attempts to write to :data:`!sys.stdout` if it is ``None``. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *expand* parameter. diff --git a/Doc/library/select.rst b/Doc/library/select.rst index 6c4a55612180a3..09563af14d018a 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -89,7 +89,7 @@ The module defines the following: The *flags* parameter. ``select.EPOLL_CLOEXEC`` is used by default now. Use :func:`os.set_inheritable` to make the file descriptor inheritable. - .. versionchanged:: next + .. versionchanged:: 3.15 When CPython is built, this function may be disabled using :option:`--disable-epoll`. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2099ef56169ede..3d943566be34ff 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2775,8 +2775,22 @@ expression support in the :mod:`re` module). .. method:: str.swapcase() Return a copy of the string with uppercase characters converted to lowercase and - vice versa. Note that it is not necessarily true that - ``s.swapcase().swapcase() == s``. + vice versa. For example: + + .. doctest:: + + >>> 'Hello World'.swapcase() + 'hELLO wORLD' + + Note that it is not necessarily true that ``s.swapcase().swapcase() == s``. + For example: + + .. doctest:: + + >>> 'straße'.swapcase().swapcase() + 'strasse' + + See also :meth:`str.lower` and :meth:`str.upper`. .. method:: str.title() @@ -3751,7 +3765,7 @@ arbitrary binary data. The bytearray version of this method does *not* operate in place - it always produces a new object, even if no changes were made. - .. versionchanged:: next + .. versionchanged:: 3.15 *count* is now supported as a keyword argument. diff --git a/Doc/library/sys.monitoring.rst b/Doc/library/sys.monitoring.rst index 4a460479e4afd7..16e6b1d6dc786b 100644 --- a/Doc/library/sys.monitoring.rst +++ b/Doc/library/sys.monitoring.rst @@ -11,9 +11,9 @@ .. note:: :mod:`!sys.monitoring` is a namespace within the :mod:`sys` module, - not an independent module, so there is no need to - ``import sys.monitoring``, simply ``import sys`` and then use - ``sys.monitoring``. + not an independent module, and ``import sys.monitoring`` would fail + with a :exc:`ModuleNotFoundError`. Instead, simply ``import sys`` + and then use ``sys.monitoring``. This namespace provides access to the functions and constants necessary to diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index aed7e7556f6666..fd67c5c0a0f513 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -158,7 +158,7 @@ The module defines three convenience functions and a public class: .. versionadded:: 3.6 - .. versionchanged:: next + .. versionchanged:: 3.15 The optional *target_time* parameter was added. @@ -247,7 +247,7 @@ Where the following options are understood: if :option:`--number` is 0, the code will run until it takes at least this many seconds (default: 0.2) - .. versionadded:: next + .. versionadded:: 3.15 .. option:: -v, --verbose diff --git a/Doc/library/wave.rst b/Doc/library/wave.rst index 9d30a14f112937..d320975708c07c 100644 --- a/Doc/library/wave.rst +++ b/Doc/library/wave.rst @@ -18,7 +18,7 @@ The module supports uncompressed PCM and IEEE floating-point WAV formats. Support for ``WAVE_FORMAT_EXTENSIBLE`` headers was added, provided that the extended format is ``KSDATAFORMAT_SUBTYPE_PCM``. -.. versionchanged:: next +.. versionchanged:: 3.15 Support for reading and writing ``WAVE_FORMAT_IEEE_FLOAT`` files was added. diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst index bbb15ce5e758c6..310ccd651e18c7 100644 --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -705,7 +705,7 @@ Functions .. versionchanged:: 3.15 *attrib* can now be a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 *parent* and *tag* are now positional-only parameters. @@ -896,7 +896,7 @@ Element Objects .. versionchanged:: 3.15 *attrib* can now be a :class:`frozendict`. - .. versionchanged:: next + .. versionchanged:: 3.15 *tag* is now a positional-only parameter. diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index d0355ce47a6504..7cbc03f5f1281e 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -654,13 +654,17 @@ Miscellaneous options .. versionadded:: 3.13 - * :samp:`-X presite={package.module}` specifies a module that should be - imported before the :mod:`site` module is executed and before the + * :samp:`-X presite={module}` or :samp:`-X presite={module:func}` specifies + an entry point that should be executed before the :mod:`site` module is + executed and before the :mod:`__main__` module exists. Therefore, the imported module isn't :mod:`__main__`. This can be used to execute code early during Python initialization. Python needs to be :ref:`built in debug mode ` for this option to exist. See also :envvar:`PYTHON_PRESITE`. + .. versionchanged:: next + Accept also ``module:func`` entry point format. + .. versionadded:: 3.13 * :samp:`-X gil={0,1}` forces the GIL to be disabled or enabled, @@ -1458,4 +1462,7 @@ Debug-mode variables Needs Python configured with the :option:`--with-pydebug` build option. + .. versionchanged:: next + Accept also ``module:func`` entry point format. + .. versionadded:: 3.13 diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index cc6aafe80f810d..bf25de7cc90c6c 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -472,7 +472,7 @@ General Options :manpage:`epoll_create1 ` is available but incompatible with Linux semantics. - .. versionadded:: next + .. versionadded:: 3.15 C compiler options @@ -1574,6 +1574,12 @@ Compiler flags .. versionadded:: 3.7 +.. envvar:: CFLAGS_CEVAL + + Flags used to compile ``Python/ceval.c``. + + .. versionadded:: 3.14.5 + .. envvar:: CCSHARED Compiler flags used to build a shared library. diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 68e2911deeb4f1..c754b634ecccfa 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -822,6 +822,17 @@ http.cookies (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.) +http.server +----------- + +* The logging of :mod:`~http.server.BaseHTTPRequestHandler`, + as used by the :ref:`command-line interface `, + is colored by default. + This can be controlled with :ref:`environment variables + `. + (Contributed by Hugo van Kemenade in :gh:`146292`.) + + inspect ------- @@ -1097,6 +1108,10 @@ tarfile timeit ------ +* The output of the :mod:`timeit` command-line interface is colored by default. + This can be controlled with + :ref:`environment variables `. + (Contributed by Hugo van Kemenade in :gh:`146609`.) * The command-line interface now colorizes error tracebacks by default. This can be controlled with :ref:`environment variables `. @@ -1294,6 +1309,25 @@ warnings (Contributed by Serhiy Storchaka in :gh:`135801`.) +wave +---- + +* Added support for IEEE floating-point WAVE audio + (``WAVE_FORMAT_IEEE_FLOAT``) in :mod:`wave`. + +* Added :meth:`wave.Wave_read.getformat`, :meth:`wave.Wave_write.getformat`, + and :meth:`wave.Wave_write.setformat` for explicit frame format handling. + +* :meth:`wave.Wave_write.setparams` accepts both 7-item tuples including + ``format`` and 6-item tuples for backwards compatibility (defaulting to + ``WAVE_FORMAT_PCM``). + +* ``WAVE_FORMAT_IEEE_FLOAT`` output now includes a ``fact`` chunk, + as required for non-PCM WAVE formats. + +(Contributed by Lionel Koenig and Michiel W. Beijen in :gh:`60729`.) + + xml.parsers.expat ----------------- @@ -1394,7 +1428,6 @@ end users running Python do not need LLVM installed. Instructions for installing LLVM can be found in the `JIT compiler documentation `__ for all supported platforms. - (Contributed by Savannah Ostrowski in :gh:`140973`.) .. rubric:: A new tracing frontend @@ -1406,7 +1439,6 @@ code. For example, simple Python object creation is now understood by the supported. This was made possible by an overhauled JIT tracing frontend that records actual execution paths through code, rather than estimating them as the previous implementation did. - (Contributed by Ken Jin in :gh:`139109`. Support for Windows added by Mark Shannon in :gh:`141703`.) @@ -1416,7 +1448,6 @@ A basic form of register allocation has been added to the JIT compiler's optimizer. This allows the JIT compiler to avoid certain stack operations altogether and instead operate on registers. This allows the JIT to produce more efficient traces by avoiding reads and writes to memory. - (Contributed by Mark Shannon in :gh:`135379`.) .. rubric:: More JIT optimizations @@ -1424,27 +1455,33 @@ more efficient traces by avoiding reads and writes to memory. More `constant-propagation `__ is now performed. This means when the JIT compiler detects that certain user code results in constants, the code can be simplified by the JIT. - (Contributed by Ken Jin and Savannah Ostrowski in :gh:`132732`.) -The JIT avoids :term:`reference count`\ s where possible. This generally +:term:`Reference count`\ s are avoided whenever it is safe to do so. This generally reduces the cost of most operations in Python. - (Contributed by Ken Jin, Donghee Na, Zheao Li, Hai Zhu, Savannah Ostrowski, Reiden Ong, Noam Cohen, Tomas Roun, PuQing, Cajetan Rodrigues, and Sacul in :gh:`134584`.) +The JIT optimizer now supports significantly more operations than in 3.14. +(Contributed by Kumar Aditya, Ken Jin, and Sacul in :gh:`131798`.) + .. rubric:: Better machine code generation The JIT compiler's machine code generator now produces better machine code for x86-64 and AArch64 macOS and Linux targets. In general, users should experience lower memory usage for generated machine code and more efficient -machine code versus the old JIT. - +machine code versus 3.14. (Contributed by Brandt Bucher in :gh:`136528` and :gh:`136528`. Implementation for AArch64 contributed by Mark Shannon in :gh:`139855`. Additional optimizations for AArch64 contributed by Mark Shannon and Diego Russo in :gh:`140683` and :gh:`142305`.) +.. rubric:: Maintainability + +The JIT optimizer's operations have been simplified. +This was made possible by a refactoring of JIT data structures. +(Contributed by Zhongtian Zheng in :gh:`148211` and Hai Zhu in :gh:`143421`.) + Removed ======== @@ -1563,21 +1600,6 @@ typing wave ---- -* Added support for IEEE floating-point WAVE audio - (``WAVE_FORMAT_IEEE_FLOAT``) in :mod:`wave`. - -* Added :meth:`wave.Wave_read.getformat`, :meth:`wave.Wave_write.getformat`, - and :meth:`wave.Wave_write.setformat` for explicit frame format handling. - -* :meth:`wave.Wave_write.setparams` accepts both 7-item tuples including - ``format`` and 6-item tuples for backwards compatibility (defaulting to - ``WAVE_FORMAT_PCM``). - -* ``WAVE_FORMAT_IEEE_FLOAT`` output now includes a ``fact`` chunk, - as required for non-PCM WAVE formats. - -(Contributed by Lionel Koenig and Michiel W. Beijen in :gh:`60729`.) - * Removed the ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes, which were deprecated since Python 3.13. @@ -1781,6 +1803,17 @@ New features * Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array. (Contributed by Victor Stinner in :gh:`111489`.) +* Add functions that are guaranteed to be safe for use in + :c:member:`~PyTypeObject.tp_traverse` handlers: + :c:func:`PyObject_GetTypeData_DuringGC`, + :c:func:`PyObject_GetItemData_DuringGC`, + :c:func:`PyType_GetModuleState_DuringGC`, + :c:func:`PyModule_GetState_DuringGC`, :c:func:`PyModule_GetToken_DuringGC`, + :c:func:`PyType_GetBaseByToken_DuringGC`, + :c:func:`PyType_GetModule_DuringGC`, + :c:func:`PyType_GetModuleByToken_DuringGC`. + (Contributed by Petr Viktorin in :gh:`145925`.) + * Add :c:func:`PyObject_Dump` to dump an object to ``stderr``. It should only be used for debugging. (Contributed by Victor Stinner in :gh:`141070`.) diff --git a/Include/cpython/critical_section.h b/Include/cpython/critical_section.h index 4fc46fefb93a24..bcba32da412f32 100644 --- a/Include/cpython/critical_section.h +++ b/Include/cpython/critical_section.h @@ -2,15 +2,6 @@ # error "this header file must not be included directly" #endif -// Python critical sections -// -// Conceptually, critical sections are a deadlock avoidance layer on top of -// per-object locks. These helpers, in combination with those locks, replace -// our usage of the global interpreter lock to provide thread-safety for -// otherwise thread-unsafe objects, such as dict. -// -// NOTE: These APIs are no-ops in non-free-threaded builds. -// // Straightforward per-object locking could introduce deadlocks that were not // present when running with the GIL. Threads may hold locks for multiple // objects simultaneously because Python operations can nest. If threads were @@ -43,52 +34,19 @@ // `_PyThreadState_Attach()`, it resumes the top-most (i.e., most recent) // critical section by reacquiring the associated lock or locks. See // `_PyCriticalSection_Resume()`. -// -// NOTE: Only the top-most critical section is guaranteed to be active. -// Operations that need to lock two objects at once must use -// `Py_BEGIN_CRITICAL_SECTION2()`. You *CANNOT* use nested critical sections -// to lock more than one object at once, because the inner critical section -// may suspend the outer critical sections. This API does not provide a way -// to lock more than two objects at once (though it could be added later -// if actually needed). -// -// NOTE: Critical sections implicitly behave like reentrant locks because -// attempting to acquire the same lock will suspend any outer (earlier) -// critical sections. However, they are less efficient for this use case than -// purposefully designed reentrant locks. -// -// Example usage: -// Py_BEGIN_CRITICAL_SECTION(op); -// ... -// Py_END_CRITICAL_SECTION(); -// -// To lock two objects at once: -// Py_BEGIN_CRITICAL_SECTION2(op1, op2); -// ... -// Py_END_CRITICAL_SECTION2(); - -typedef struct PyCriticalSection PyCriticalSection; -typedef struct PyCriticalSection2 PyCriticalSection2; - -PyAPI_FUNC(void) -PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op); PyAPI_FUNC(void) PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m); -PyAPI_FUNC(void) -PyCriticalSection_End(PyCriticalSection *c); - -PyAPI_FUNC(void) -PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b); - PyAPI_FUNC(void) PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2); -PyAPI_FUNC(void) -PyCriticalSection2_End(PyCriticalSection2 *c); - #ifndef Py_GIL_DISABLED +#undef Py_BEGIN_CRITICAL_SECTION +#undef Py_END_CRITICAL_SECTION +#undef Py_BEGIN_CRITICAL_SECTION2 +#undef Py_END_CRITICAL_SECTION2 + # define Py_BEGIN_CRITICAL_SECTION(op) \ { # define Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex) \ @@ -101,54 +59,17 @@ PyCriticalSection2_End(PyCriticalSection2 *c); { # define Py_END_CRITICAL_SECTION2() \ } -#else /* !Py_GIL_DISABLED */ - -// NOTE: the contents of this struct are private and may change betweeen -// Python releases without a deprecation period. -struct PyCriticalSection { - // Tagged pointer to an outer active critical section (or 0). - uintptr_t _cs_prev; - - // Mutex used to protect critical section - PyMutex *_cs_mutex; -}; - -// A critical section protected by two mutexes. Use -// Py_BEGIN_CRITICAL_SECTION2 and Py_END_CRITICAL_SECTION2. -// NOTE: the contents of this struct are private and may change betweeen -// Python releases without a deprecation period. -struct PyCriticalSection2 { - PyCriticalSection _cs_base; - PyMutex *_cs_mutex2; -}; - -# define Py_BEGIN_CRITICAL_SECTION(op) \ - { \ - PyCriticalSection _py_cs; \ - PyCriticalSection_Begin(&_py_cs, _PyObject_CAST(op)) +#else /* !Py_GIL_DISABLED */ # define Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex) \ { \ PyCriticalSection _py_cs; \ PyCriticalSection_BeginMutex(&_py_cs, mutex) -# define Py_END_CRITICAL_SECTION() \ - PyCriticalSection_End(&_py_cs); \ - } - -# define Py_BEGIN_CRITICAL_SECTION2(a, b) \ - { \ - PyCriticalSection2 _py_cs2; \ - PyCriticalSection2_Begin(&_py_cs2, _PyObject_CAST(a), _PyObject_CAST(b)) - # define Py_BEGIN_CRITICAL_SECTION2_MUTEX(m1, m2) \ { \ PyCriticalSection2 _py_cs2; \ PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2) -# define Py_END_CRITICAL_SECTION2() \ - PyCriticalSection2_End(&_py_cs2); \ - } - -#endif +#endif /* !Py_GIL_DISABLED */ diff --git a/Include/cpython/object.h b/Include/cpython/object.h index acee45fc31b79b..80d30c7765fdb0 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -442,6 +442,7 @@ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate); PyAPI_FUNC(void *) PyObject_GetItemData(PyObject *obj); +PyAPI_FUNC(void *) PyObject_GetItemData_DuringGC(PyObject *obj); PyAPI_FUNC(int) PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg); PyAPI_FUNC(void) PyObject_ClearManagedDict(PyObject *obj); diff --git a/Include/critical_section.h b/Include/critical_section.h index 3b37615a8b17e2..4178ef7a4c12d5 100644 --- a/Include/critical_section.h +++ b/Include/critical_section.h @@ -4,6 +4,91 @@ extern "C" { #endif +// Python critical sections +// +// Conceptually, critical sections are a deadlock avoidance layer on top of +// per-object locks. These helpers, in combination with those locks, replace +// our usage of the global interpreter lock to provide thread-safety for +// otherwise thread-unsafe objects, such as dict. +// +// NOTE: These APIs are no-ops in non-free-threaded builds. +// +// NOTE: Only the top-most critical section is guaranteed to be active. +// Operations that need to lock two objects at once must use +// `Py_BEGIN_CRITICAL_SECTION2()`. You *CANNOT* use nested critical sections +// to lock more than one object at once, because the inner critical section +// may suspend the outer critical sections. This API does not provide a way +// to lock more than two objects at once (though it could be added later +// if actually needed). +// +// NOTE: Critical sections implicitly behave like reentrant locks because +// attempting to acquire the same lock will suspend any outer (earlier) +// critical sections. However, they are less efficient for this use case than +// purposefully designed reentrant locks. +// +// Example usage: +// Py_BEGIN_CRITICAL_SECTION(op); +// ... +// Py_END_CRITICAL_SECTION(); +// +// To lock two objects at once: +// Py_BEGIN_CRITICAL_SECTION2(op1, op2); +// ... +// Py_END_CRITICAL_SECTION2(); + +// NOTE: the contents of this struct are private and their meaning may +// change betweeen Python releases without a deprecation period. +typedef struct PyCriticalSection { + // Tagged pointer to an outer active critical section (or 0). + uintptr_t _cs_prev; + + // Mutex used to protect critical section + struct PyMutex *_cs_mutex; + + // Space for Stable ABI additions + void *_cs_reserved; +} PyCriticalSection; + +// A critical section protected by two mutexes. Use +// Py_BEGIN_CRITICAL_SECTION2 and Py_END_CRITICAL_SECTION2. +// NOTE: the contents of this struct are private and may change betweeen +// Python releases without a deprecation period. +typedef struct PyCriticalSection2 { + PyCriticalSection _cs_base; + + struct PyMutex *_cs_mutex2; +} PyCriticalSection2; + +PyAPI_FUNC(void) +PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op); + +PyAPI_FUNC(void) +PyCriticalSection_End(PyCriticalSection *c); + +PyAPI_FUNC(void) +PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b); + +PyAPI_FUNC(void) +PyCriticalSection2_End(PyCriticalSection2 *c); + +# define Py_BEGIN_CRITICAL_SECTION(op) \ + { \ + PyCriticalSection _py_cs; \ + PyCriticalSection_Begin(&_py_cs, _PyObject_CAST(op)) + +# define Py_END_CRITICAL_SECTION() \ + PyCriticalSection_End(&_py_cs); \ + } + +# define Py_BEGIN_CRITICAL_SECTION2(a, b) \ + { \ + PyCriticalSection2 _py_cs2; \ + PyCriticalSection2_Begin(&_py_cs2, _PyObject_CAST(a), _PyObject_CAST(b)) + +# define Py_END_CRITICAL_SECTION2() \ + PyCriticalSection2_End(&_py_cs2); \ + } + #ifndef Py_LIMITED_API # define Py_CPYTHON_CRITICAL_SECTION_H # include "cpython/critical_section.h" diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index 2479630021bfe3..94a1f687b7b150 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -433,19 +433,19 @@ _Py_VectorCallInstrumentation_StackRefSteal( PyThreadState* tstate); PyAPI_FUNC(PyObject *) -_Py_BuiltinCallFast_StackRefSteal( +_Py_BuiltinCallFast_StackRef( _PyStackRef callable, _PyStackRef *arguments, int total_args); PyAPI_FUNC(PyObject *) -_Py_BuiltinCallFastWithKeywords_StackRefSteal( +_Py_BuiltinCallFastWithKeywords_StackRef( _PyStackRef callable, _PyStackRef *arguments, int total_args); PyAPI_FUNC(PyObject *) -_PyCallMethodDescriptorFast_StackRefSteal( +_PyCallMethodDescriptorFast_StackRef( _PyStackRef callable, PyCFunctionFast cfunc, PyObject *self, @@ -453,7 +453,7 @@ _PyCallMethodDescriptorFast_StackRefSteal( int total_args); PyAPI_FUNC(PyObject *) -_PyCallMethodDescriptorFastWithKeywords_StackRefSteal( +_PyCallMethodDescriptorFastWithKeywords_StackRef( _PyStackRef callable, PyCFunctionFastWithKeywords cfunc, PyObject *self, @@ -461,7 +461,7 @@ _PyCallMethodDescriptorFastWithKeywords_StackRefSteal( int total_args); PyAPI_FUNC(PyObject *) -_Py_CallBuiltinClass_StackRefSteal( +_Py_CallBuiltinClass_StackRef( _PyStackRef callable, _PyStackRef *arguments, int total_args); diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index d58539fa846563..5bbea187394db6 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -292,7 +292,7 @@ _PyDict_NotifyEvent(PyDict_WatchEvent event, PyObject *value) { assert(Py_REFCNT((PyObject*)mp) > 0); - int watcher_bits = mp->_ma_watcher_tag & DICT_WATCHER_MASK; + int watcher_bits = FT_ATOMIC_LOAD_UINT64_RELAXED(mp->_ma_watcher_tag) & DICT_WATCHER_MASK; if (watcher_bits) { RARE_EVENT_STAT_INC(watched_dict_modification); _PyDict_SendEvent(watcher_bits, event, mp, key, value); @@ -368,7 +368,7 @@ PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *); static inline Py_ssize_t _PyDict_UniqueId(PyDictObject *mp) { - return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT); + return (Py_ssize_t)(FT_ATOMIC_LOAD_UINT64_RELAXED(mp->_ma_watcher_tag) >> DICT_UNIQUE_ID_SHIFT); } static inline void diff --git a/Include/internal/pycore_instruments.h b/Include/internal/pycore_instruments.h index 3775b074ecf54c..1da8237e93f766 100644 --- a/Include/internal/pycore_instruments.h +++ b/Include/internal/pycore_instruments.h @@ -64,9 +64,6 @@ PyAPI_FUNC(void) _Py_call_instrumentation_exc2(PyThreadState *tstate, int event, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1); -extern int -_Py_Instrumentation_GetLine(PyCodeObject *code, int index); - PyAPI_DATA(PyObject) _PyInstrumentation_MISSING; PyAPI_DATA(PyObject) _PyInstrumentation_DISABLE; @@ -122,6 +119,8 @@ typedef struct _PyCoMonitoringData { uint8_t *per_instruction_tools; } _PyCoMonitoringData; +extern int +_Py_Instrumentation_GetLine(PyCodeObject *code, _PyCoLineInstrumentationData *line_data, int index); #ifdef __cplusplus } diff --git a/Include/internal/pycore_moduleobject.h b/Include/internal/pycore_moduleobject.h index 7882ce03323561..5bcfd17cec4627 100644 --- a/Include/internal/pycore_moduleobject.h +++ b/Include/internal/pycore_moduleobject.h @@ -53,11 +53,13 @@ static inline PyModuleDef *_PyModule_GetDefOrNull(PyObject *arg) { return NULL; } +// Get md_token. Used in _DuringGC functions; must have no side effects. static inline PyModuleDef *_PyModule_GetToken(PyObject *arg) { PyModuleObject *mod = _PyModule_CAST(arg); return (PyModuleDef *)mod->md_token; } +// Get md_state. Used in _DuringGC functions; must have no side effects. static inline void* _PyModule_GetState(PyObject* mod) { return _PyModule_CAST(mod)->md_state; } diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 916f3b8ee863c4..61d8b7dc189d6c 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -1123,9 +1123,9 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [CALL_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_BOUND_METHOD_GENERAL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG | HAS_RECORDS_VALUE_FLAG }, - [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, - [CALL_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, + [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, + [CALL_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_EX_NON_PY_GENERAL] = { true, INSTR_FMT_IXC, HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [CALL_EX_PY] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG | HAS_RECORDS_VALUE_FLAG }, @@ -1139,9 +1139,9 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [CALL_KW_PY] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG }, [CALL_LEN] = { true, INSTR_FMT_IXC00, HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [CALL_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, - [CALL_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, - [CALL_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, + [CALL_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_NON_PY_GENERAL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [CALL_PY_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG | HAS_RECORDS_VALUE_FLAG }, @@ -1255,9 +1255,9 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [LOAD_SPECIAL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [LOAD_SUPER_ATTR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [LOAD_SUPER_ATTR_ATTR] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, - [LOAD_SUPER_ATTR_METHOD] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, + [LOAD_SUPER_ATTR_METHOD] = { true, INSTR_FMT_IBC, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [MAKE_CELL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, - [MAKE_FUNCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [MAKE_FUNCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [MAP_ADD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [MATCH_CLASS] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [MATCH_KEYS] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, @@ -1289,7 +1289,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [SET_FUNCTION_ATTRIBUTE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, [SET_UPDATE] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [STORE_ATTR] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, - [STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ESCAPES_FLAG }, + [STORE_ATTR_INSTANCE_VALUE] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [STORE_ATTR_SLOT] = { true, INSTR_FMT_IXC000, HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [STORE_ATTR_WITH_HINT] = { true, INSTR_FMT_IBC000, HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_DEOPT_FLAG | HAS_EXIT_FLAG | HAS_ESCAPES_FLAG | HAS_RECORDS_VALUE_FLAG }, [STORE_DEREF] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_FREE_FLAG | HAS_ESCAPES_FLAG }, @@ -1371,13 +1371,13 @@ _PyOpcode_macro_expansion[256] = { [BUILD_STRING] = { .nuops = 1, .uops = { { _BUILD_STRING, OPARG_SIMPLE, 0 } } }, [BUILD_TEMPLATE] = { .nuops = 1, .uops = { { _BUILD_TEMPLATE, OPARG_SIMPLE, 0 } } }, [BUILD_TUPLE] = { .nuops = 1, .uops = { { _BUILD_TUPLE, OPARG_SIMPLE, 0 } } }, - [CALL_ALLOC_AND_ENTER_INIT] = { .nuops = 5, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_AND_ALLOCATE_OBJECT, 2, 1 }, { _CREATE_INIT_FRAME, OPARG_SIMPLE, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, + [CALL_ALLOC_AND_ENTER_INIT] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_OBJECT, 2, 1 }, { _ALLOCATE_OBJECT, OPARG_SIMPLE, 3 }, { _CREATE_INIT_FRAME, OPARG_SIMPLE, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, [CALL_BOUND_METHOD_EXACT_ARGS] = { .nuops = 11, .uops = { { _RECORD_BOUND_METHOD, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_CALL_BOUND_METHOD_EXACT_ARGS, OPARG_SIMPLE, 1 }, { _INIT_CALL_BOUND_METHOD_EXACT_ARGS, OPARG_SIMPLE, 1 }, { _CHECK_FUNCTION_VERSION, 2, 1 }, { _CHECK_FUNCTION_EXACT_ARGS, OPARG_SIMPLE, 3 }, { _CHECK_STACK_SPACE, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_REMAINING, OPARG_SIMPLE, 3 }, { _INIT_CALL_PY_EXACT_ARGS, OPARG_SIMPLE, 3 }, { _SAVE_RETURN_OFFSET, OPARG_SAVE_RETURN_OFFSET, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, [CALL_BOUND_METHOD_GENERAL] = { .nuops = 8, .uops = { { _RECORD_BOUND_METHOD, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_METHOD_VERSION, 2, 1 }, { _EXPAND_METHOD, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_REMAINING, OPARG_SIMPLE, 3 }, { _PY_FRAME_GENERAL, OPARG_SIMPLE, 3 }, { _SAVE_RETURN_OFFSET, OPARG_SAVE_RETURN_OFFSET, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, - [CALL_BUILTIN_CLASS] = { .nuops = 3, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _CALL_BUILTIN_CLASS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_BUILTIN_FAST] = { .nuops = 4, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_FAST, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_FAST, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 4, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_BUILTIN_O] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_O, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_O, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_BUILTIN_CLASS] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_CLASS, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_CLASS, OPARG_SIMPLE, 3 }, { _POP_TOP_OPARG, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_BUILTIN_FAST] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_FAST, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_FAST, OPARG_SIMPLE, 3 }, { _POP_TOP_OPARG, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _POP_TOP_OPARG, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_BUILTIN_O] = { .nuops = 7, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_BUILTIN_O, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_LIMIT, OPARG_SIMPLE, 3 }, { _CALL_BUILTIN_O, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_EX_NON_PY_GENERAL] = { .nuops = 4, .uops = { { _CHECK_IS_NOT_PY_CALLABLE_EX, OPARG_SIMPLE, 1 }, { _MAKE_CALLARGS_A_TUPLE, OPARG_SIMPLE, 1 }, { _CALL_FUNCTION_EX_NON_PY_GENERAL, OPARG_SIMPLE, 1 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 1 } } }, [CALL_EX_PY] = { .nuops = 7, .uops = { { _RECORD_4OS, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _MAKE_CALLARGS_A_TUPLE, OPARG_SIMPLE, 1 }, { _CHECK_IS_PY_CALLABLE_EX, OPARG_SIMPLE, 1 }, { _PY_FRAME_EX, OPARG_SIMPLE, 1 }, { _SAVE_RETURN_OFFSET, OPARG_SAVE_RETURN_OFFSET, 1 }, { _PUSH_FRAME, OPARG_SIMPLE, 1 } } }, [CALL_INTRINSIC_1] = { .nuops = 2, .uops = { { _CALL_INTRINSIC_1, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 } } }, @@ -1388,9 +1388,9 @@ _PyOpcode_macro_expansion[256] = { [CALL_KW_PY] = { .nuops = 6, .uops = { { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_FUNCTION_VERSION_KW, 2, 1 }, { _CHECK_RECURSION_REMAINING, OPARG_SIMPLE, 3 }, { _PY_FRAME_KW, OPARG_SIMPLE, 3 }, { _SAVE_RETURN_OFFSET, OPARG_SAVE_RETURN_OFFSET, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, [CALL_LEN] = { .nuops = 5, .uops = { { _GUARD_NOS_NULL, OPARG_SIMPLE, 3 }, { _GUARD_CALLABLE_LEN, OPARG_SIMPLE, 3 }, { _CALL_LEN, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 } } }, [CALL_LIST_APPEND] = { .nuops = 6, .uops = { { _GUARD_CALLABLE_LIST_APPEND, OPARG_SIMPLE, 3 }, { _GUARD_NOS_NOT_NULL, OPARG_SIMPLE, 3 }, { _GUARD_NOS_LIST, OPARG_SIMPLE, 3 }, { _CALL_LIST_APPEND, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 } } }, - [CALL_METHOD_DESCRIPTOR_FAST] = { .nuops = 3, .uops = { { _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_FAST, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .nuops = 4, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 5, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_LIMIT, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_NOARGS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_METHOD_DESCRIPTOR_FAST] = { .nuops = 5, .uops = { { _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_FAST, OPARG_SIMPLE, 3 }, { _POP_TOP_OPARG, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .nuops = 6, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _POP_TOP_OPARG, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 7, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_LIMIT, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_NOARGS, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_METHOD_DESCRIPTOR_O] = { .nuops = 8, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _GUARD_CALLABLE_METHOD_DESCRIPTOR_O, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_LIMIT, OPARG_SIMPLE, 3 }, { _CALL_METHOD_DESCRIPTOR_O, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_NON_PY_GENERAL] = { .nuops = 4, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _CHECK_IS_NOT_PY_CALLABLE, OPARG_SIMPLE, 3 }, { _CALL_NON_PY_GENERAL, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_PY_EXACT_ARGS] = { .nuops = 9, .uops = { { _RECORD_CALLABLE, OPARG_SIMPLE, 0 }, { _CHECK_PEP_523, OPARG_SIMPLE, 1 }, { _CHECK_FUNCTION_VERSION, 2, 1 }, { _CHECK_FUNCTION_EXACT_ARGS, OPARG_SIMPLE, 3 }, { _CHECK_STACK_SPACE, OPARG_SIMPLE, 3 }, { _CHECK_RECURSION_REMAINING, OPARG_SIMPLE, 3 }, { _INIT_CALL_PY_EXACT_ARGS, OPARG_SIMPLE, 3 }, { _SAVE_RETURN_OFFSET, OPARG_SAVE_RETURN_OFFSET, 3 }, { _PUSH_FRAME, OPARG_SIMPLE, 3 } } }, @@ -1473,9 +1473,9 @@ _PyOpcode_macro_expansion[256] = { [LOAD_SMALL_INT] = { .nuops = 1, .uops = { { _LOAD_SMALL_INT, OPARG_SIMPLE, 0 } } }, [LOAD_SPECIAL] = { .nuops = 2, .uops = { { _INSERT_NULL, OPARG_SIMPLE, 0 }, { _LOAD_SPECIAL, OPARG_SIMPLE, 0 } } }, [LOAD_SUPER_ATTR_ATTR] = { .nuops = 1, .uops = { { _LOAD_SUPER_ATTR_ATTR, OPARG_SIMPLE, 1 } } }, - [LOAD_SUPER_ATTR_METHOD] = { .nuops = 1, .uops = { { _LOAD_SUPER_ATTR_METHOD, OPARG_SIMPLE, 1 } } }, + [LOAD_SUPER_ATTR_METHOD] = { .nuops = 3, .uops = { { _RECORD_NOS, OPARG_SIMPLE, 0 }, { _GUARD_LOAD_SUPER_ATTR_METHOD, OPARG_SIMPLE, 1 }, { _LOAD_SUPER_ATTR_METHOD, OPARG_SIMPLE, 1 } } }, [MAKE_CELL] = { .nuops = 1, .uops = { { _MAKE_CELL, OPARG_SIMPLE, 0 } } }, - [MAKE_FUNCTION] = { .nuops = 1, .uops = { { _MAKE_FUNCTION, OPARG_SIMPLE, 0 } } }, + [MAKE_FUNCTION] = { .nuops = 2, .uops = { { _MAKE_FUNCTION, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 } } }, [MAP_ADD] = { .nuops = 1, .uops = { { _MAP_ADD, OPARG_SIMPLE, 0 } } }, [MATCH_CLASS] = { .nuops = 4, .uops = { { _MATCH_CLASS, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 } } }, [MATCH_KEYS] = { .nuops = 1, .uops = { { _MATCH_KEYS, OPARG_SIMPLE, 0 } } }, @@ -1501,7 +1501,7 @@ _PyOpcode_macro_expansion[256] = { [SET_FUNCTION_ATTRIBUTE] = { .nuops = 1, .uops = { { _SET_FUNCTION_ATTRIBUTE, OPARG_SIMPLE, 0 } } }, [SET_UPDATE] = { .nuops = 2, .uops = { { _SET_UPDATE, OPARG_SIMPLE, 0 }, { _POP_TOP, OPARG_SIMPLE, 0 } } }, [STORE_ATTR] = { .nuops = 1, .uops = { { _STORE_ATTR, OPARG_SIMPLE, 3 } } }, - [STORE_ATTR_INSTANCE_VALUE] = { .nuops = 5, .uops = { { _LOCK_OBJECT, OPARG_SIMPLE, 1 }, { _GUARD_TYPE_VERSION_LOCKED, 2, 1 }, { _GUARD_DORV_NO_DICT, OPARG_SIMPLE, 3 }, { _STORE_ATTR_INSTANCE_VALUE, 1, 3 }, { _POP_TOP, OPARG_SIMPLE, 4 } } }, + [STORE_ATTR_INSTANCE_VALUE] = { .nuops = 6, .uops = { { _RECORD_TOS_TYPE, OPARG_SIMPLE, 1 }, { _LOCK_OBJECT, OPARG_SIMPLE, 1 }, { _GUARD_TYPE_VERSION_LOCKED, 2, 1 }, { _GUARD_DORV_NO_DICT, OPARG_SIMPLE, 3 }, { _STORE_ATTR_INSTANCE_VALUE, 1, 3 }, { _POP_TOP, OPARG_SIMPLE, 4 } } }, [STORE_ATTR_SLOT] = { .nuops = 4, .uops = { { _RECORD_TOS_TYPE, OPARG_SIMPLE, 1 }, { _GUARD_TYPE_VERSION, 2, 1 }, { _STORE_ATTR_SLOT, 1, 3 }, { _POP_TOP, OPARG_SIMPLE, 4 } } }, [STORE_ATTR_WITH_HINT] = { .nuops = 4, .uops = { { _RECORD_TOS_TYPE, OPARG_SIMPLE, 1 }, { _GUARD_TYPE_VERSION, 2, 1 }, { _STORE_ATTR_WITH_HINT, 1, 3 }, { _POP_TOP, OPARG_SIMPLE, 4 } } }, [STORE_DEREF] = { .nuops = 1, .uops = { { _STORE_DEREF, OPARG_SIMPLE, 0 } } }, diff --git a/Include/internal/pycore_optimizer.h b/Include/internal/pycore_optimizer.h index cf01c620476ff7..e7b688333d9ced 100644 --- a/Include/internal/pycore_optimizer.h +++ b/Include/internal/pycore_optimizer.h @@ -424,8 +424,6 @@ extern PyCodeObject *_Py_uop_sym_get_probable_func_code(JitOptRef sym); extern PyObject *_Py_uop_sym_get_probable_value(JitOptRef sym); extern PyTypeObject *_Py_uop_sym_get_probable_type(JitOptRef sym); extern JitOptRef *_Py_uop_sym_set_stack_depth(JitOptContext *ctx, int stack_depth, JitOptRef *current_sp); -extern uint32_t _Py_uop_sym_get_func_version(JitOptRef ref); -bool _Py_uop_sym_set_func_version(JitOptContext *ctx, JitOptRef ref, uint32_t version); extern void _Py_uop_abstractcontext_init(JitOptContext *ctx, _PyBloomFilter *dependencies); extern void _Py_uop_abstractcontext_fini(JitOptContext *ctx); diff --git a/Include/internal/pycore_optimizer_types.h b/Include/internal/pycore_optimizer_types.h index 8ecfbea387460b..a722652cc8163a 100644 --- a/Include/internal/pycore_optimizer_types.h +++ b/Include/internal/pycore_optimizer_types.h @@ -36,7 +36,6 @@ typedef enum _JitSymType { JIT_SYM_NON_NULL_TAG = 3, JIT_SYM_BOTTOM_TAG = 4, JIT_SYM_TYPE_VERSION_TAG = 5, - JIT_SYM_FUNC_VERSION_TAG = 6, JIT_SYM_KNOWN_CLASS_TAG = 7, JIT_SYM_KNOWN_VALUE_TAG = 8, JIT_SYM_TUPLE_TAG = 9, diff --git a/Include/internal/pycore_pyatomic_ft_wrappers.h b/Include/internal/pycore_pyatomic_ft_wrappers.h index c0f859a23e10b8..3155481bb5c36b 100644 --- a/Include/internal/pycore_pyatomic_ft_wrappers.h +++ b/Include/internal/pycore_pyatomic_ft_wrappers.h @@ -49,6 +49,8 @@ extern "C" { _Py_atomic_load_uint16_relaxed(&value) #define FT_ATOMIC_LOAD_UINT32_RELAXED(value) \ _Py_atomic_load_uint32_relaxed(&value) +#define FT_ATOMIC_LOAD_UINT64_RELAXED(value) \ + _Py_atomic_load_uint64_relaxed(&value) #define FT_ATOMIC_LOAD_ULONG_RELAXED(value) \ _Py_atomic_load_ulong_relaxed(&value) #define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) \ @@ -71,6 +73,12 @@ extern "C" { _Py_atomic_store_uint16_relaxed(&value, new_value) #define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) \ _Py_atomic_store_uint32_relaxed(&value, new_value) +#define FT_ATOMIC_AND_UINT64(value, new_value) \ + (void)_Py_atomic_and_uint64(&value, new_value) +#define FT_ATOMIC_OR_UINT64(value, new_value) \ + (void)_Py_atomic_or_uint64(&value, new_value) +#define FT_ATOMIC_ADD_UINT64(value, new_value) \ + (void)_Py_atomic_add_uint64(&value, new_value) #define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) \ _Py_atomic_store_char_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_CHAR_RELAXED(value) \ @@ -146,6 +154,7 @@ extern "C" { #define FT_ATOMIC_LOAD_UINT8_RELAXED(value) value #define FT_ATOMIC_LOAD_UINT16_RELAXED(value) value #define FT_ATOMIC_LOAD_UINT32_RELAXED(value) value +#define FT_ATOMIC_LOAD_UINT64_RELAXED(value) value #define FT_ATOMIC_LOAD_ULONG_RELAXED(value) value #define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) value = new_value #define FT_ATOMIC_STORE_PTR_RELEASE(value, new_value) value = new_value @@ -157,6 +166,9 @@ extern "C" { #define FT_ATOMIC_STORE_UINT8_RELAXED(value, new_value) value = new_value #define FT_ATOMIC_STORE_UINT16_RELAXED(value, new_value) value = new_value #define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) value = new_value +#define FT_ATOMIC_AND_UINT64(value, new_value) (void)(value &= new_value) +#define FT_ATOMIC_OR_UINT64(value, new_value) (void)(value |= new_value) +#define FT_ATOMIC_ADD_UINT64(value, new_value) (void)(value += new_value) #define FT_ATOMIC_LOAD_CHAR_RELAXED(value) value #define FT_ATOMIC_STORE_CHAR_RELAXED(value, new_value) value = new_value #define FT_ATOMIC_LOAD_UCHAR_RELAXED(value) value diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h index 7fc7f343fe600f..fcd2ae9b1d1f1a 100644 --- a/Include/internal/pycore_runtime.h +++ b/Include/internal/pycore_runtime.h @@ -56,6 +56,29 @@ _PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) { } } +// Atomic so a thread that reads initialized=1 observes all writes +// from the initialization sequence (gh-146302). + +static inline int +_PyRuntimeState_GetCoreInitialized(_PyRuntimeState *runtime) { + return _Py_atomic_load_int(&runtime->core_initialized); +} + +static inline void +_PyRuntimeState_SetCoreInitialized(_PyRuntimeState *runtime, int initialized) { + _Py_atomic_store_int(&runtime->core_initialized, initialized); +} + +static inline int +_PyRuntimeState_GetInitialized(_PyRuntimeState *runtime) { + return _Py_atomic_load_int(&runtime->initialized); +} + +static inline void +_PyRuntimeState_SetInitialized(_PyRuntimeState *runtime, int initialized) { + _Py_atomic_store_int(&runtime->initialized, initialized); +} + #ifdef __cplusplus } diff --git a/Include/internal/pycore_runtime_structs.h b/Include/internal/pycore_runtime_structs.h index 05369ef9f009e6..145e66de9984ca 100644 --- a/Include/internal/pycore_runtime_structs.h +++ b/Include/internal/pycore_runtime_structs.h @@ -158,10 +158,18 @@ struct pyruntimestate { /* Is Python preinitialized? Set to 1 by Py_PreInitialize() */ int preinitialized; - /* Is Python core initialized? Set to 1 by _Py_InitializeCore() */ + /* Is Python core initialized? Set to 1 by _Py_InitializeCore(). + + Use _PyRuntimeState_GetCoreInitialized() and + _PyRuntimeState_SetCoreInitialized() to access it, + don't access it directly. */ int core_initialized; - /* Is Python fully initialized? Set to 1 by Py_Initialize() */ + /* Is Python fully initialized? Set to 1 by Py_Initialize(). + + Use _PyRuntimeState_GetInitialized() and + _PyRuntimeState_SetInitialized() to access it, + don't access it directly. */ int initialized; /* Set by Py_FinalizeEx(). Only reset to NULL if Py_Initialize() diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 188da775eb1cc7..329045b5faaa22 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -845,6 +845,18 @@ _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out) } \ } while (0) +static inline void +_PyStackRef_CloseStack(_PyStackRef *arguments, int total_args) +{ + // arguments is a pointer into the GC visible stack, + // so we must NULL out values as we clear them. + for (int i = total_args-1; i >= 0; i--) { + _PyStackRef tmp = arguments[i]; + arguments[i] = PyStackRef_NULL; + PyStackRef_CLOSE(tmp); + } +} + #ifdef __cplusplus } #endif diff --git a/Include/internal/pycore_typeobject.h b/Include/internal/pycore_typeobject.h index 9c8b00550e3980..8207de67cf17db 100644 --- a/Include/internal/pycore_typeobject.h +++ b/Include/internal/pycore_typeobject.h @@ -126,6 +126,10 @@ extern PyTypeObject _PyBufferWrapper_Type; PyAPI_FUNC(PyObject*) _PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *meth_found); +extern PyObject *_PySuper_LookupDescr(PyTypeObject *su_type, + PyTypeObject *su_obj_type, + PyObject *name); + extern PyObject* _PyType_GetFullyQualifiedName(PyTypeObject *type, char sep); // Perform the following operation, in a thread-safe way when required by the diff --git a/Include/internal/pycore_uop_ids.h b/Include/internal/pycore_uop_ids.h index dd319778b1f2e8..f587c437e74ccd 100644 --- a/Include/internal/pycore_uop_ids.h +++ b/Include/internal/pycore_uop_ids.h @@ -11,38 +11,39 @@ extern "C" { #define _EXIT_TRACE 300 #define _SET_IP 301 -#define _BINARY_OP 302 -#define _BINARY_OP_ADD_FLOAT 303 -#define _BINARY_OP_ADD_FLOAT_INPLACE 304 -#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT 305 -#define _BINARY_OP_ADD_INT 306 -#define _BINARY_OP_ADD_INT_INPLACE 307 -#define _BINARY_OP_ADD_INT_INPLACE_RIGHT 308 -#define _BINARY_OP_ADD_UNICODE 309 -#define _BINARY_OP_EXTEND 310 -#define _BINARY_OP_INPLACE_ADD_UNICODE 311 -#define _BINARY_OP_MULTIPLY_FLOAT 312 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE 313 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT 314 -#define _BINARY_OP_MULTIPLY_INT 315 -#define _BINARY_OP_MULTIPLY_INT_INPLACE 316 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT 317 -#define _BINARY_OP_SUBSCR_CHECK_FUNC 318 -#define _BINARY_OP_SUBSCR_DICT 319 -#define _BINARY_OP_SUBSCR_DICT_KNOWN_HASH 320 -#define _BINARY_OP_SUBSCR_INIT_CALL 321 -#define _BINARY_OP_SUBSCR_LIST_INT 322 -#define _BINARY_OP_SUBSCR_LIST_SLICE 323 -#define _BINARY_OP_SUBSCR_STR_INT 324 -#define _BINARY_OP_SUBSCR_TUPLE_INT 325 -#define _BINARY_OP_SUBSCR_USTR_INT 326 -#define _BINARY_OP_SUBTRACT_FLOAT 327 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE 328 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT 329 -#define _BINARY_OP_SUBTRACT_INT 330 -#define _BINARY_OP_SUBTRACT_INT_INPLACE 331 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT 332 -#define _BINARY_SLICE 333 +#define _ALLOCATE_OBJECT 302 +#define _BINARY_OP 303 +#define _BINARY_OP_ADD_FLOAT 304 +#define _BINARY_OP_ADD_FLOAT_INPLACE 305 +#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT 306 +#define _BINARY_OP_ADD_INT 307 +#define _BINARY_OP_ADD_INT_INPLACE 308 +#define _BINARY_OP_ADD_INT_INPLACE_RIGHT 309 +#define _BINARY_OP_ADD_UNICODE 310 +#define _BINARY_OP_EXTEND 311 +#define _BINARY_OP_INPLACE_ADD_UNICODE 312 +#define _BINARY_OP_MULTIPLY_FLOAT 313 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE 314 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT 315 +#define _BINARY_OP_MULTIPLY_INT 316 +#define _BINARY_OP_MULTIPLY_INT_INPLACE 317 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT 318 +#define _BINARY_OP_SUBSCR_CHECK_FUNC 319 +#define _BINARY_OP_SUBSCR_DICT 320 +#define _BINARY_OP_SUBSCR_DICT_KNOWN_HASH 321 +#define _BINARY_OP_SUBSCR_INIT_CALL 322 +#define _BINARY_OP_SUBSCR_LIST_INT 323 +#define _BINARY_OP_SUBSCR_LIST_SLICE 324 +#define _BINARY_OP_SUBSCR_STR_INT 325 +#define _BINARY_OP_SUBSCR_TUPLE_INT 326 +#define _BINARY_OP_SUBSCR_USTR_INT 327 +#define _BINARY_OP_SUBTRACT_FLOAT 328 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE 329 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT 330 +#define _BINARY_OP_SUBTRACT_INT 331 +#define _BINARY_OP_SUBTRACT_INT_INPLACE 332 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT 333 +#define _BINARY_SLICE 334 #define _BUILD_INTERPOLATION BUILD_INTERPOLATION #define _BUILD_LIST BUILD_LIST #define _BUILD_MAP BUILD_MAP @@ -51,30 +52,29 @@ extern "C" { #define _BUILD_STRING BUILD_STRING #define _BUILD_TEMPLATE BUILD_TEMPLATE #define _BUILD_TUPLE BUILD_TUPLE -#define _CALL_BUILTIN_CLASS 334 -#define _CALL_BUILTIN_FAST 335 -#define _CALL_BUILTIN_FAST_WITH_KEYWORDS 336 -#define _CALL_BUILTIN_O 337 -#define _CALL_FUNCTION_EX_NON_PY_GENERAL 338 -#define _CALL_INTRINSIC_1 339 -#define _CALL_INTRINSIC_2 340 -#define _CALL_ISINSTANCE 341 -#define _CALL_KW_NON_PY 342 -#define _CALL_LEN 343 -#define _CALL_LIST_APPEND 344 -#define _CALL_METHOD_DESCRIPTOR_FAST 345 -#define _CALL_METHOD_DESCRIPTOR_FAST_INLINE 346 -#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 347 -#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE 348 -#define _CALL_METHOD_DESCRIPTOR_NOARGS 349 -#define _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE 350 -#define _CALL_METHOD_DESCRIPTOR_O 351 -#define _CALL_METHOD_DESCRIPTOR_O_INLINE 352 -#define _CALL_NON_PY_GENERAL 353 -#define _CALL_STR_1 354 -#define _CALL_TUPLE_1 355 -#define _CALL_TYPE_1 356 -#define _CHECK_AND_ALLOCATE_OBJECT 357 +#define _CALL_BUILTIN_CLASS 335 +#define _CALL_BUILTIN_FAST 336 +#define _CALL_BUILTIN_FAST_WITH_KEYWORDS 337 +#define _CALL_BUILTIN_O 338 +#define _CALL_FUNCTION_EX_NON_PY_GENERAL 339 +#define _CALL_INTRINSIC_1 340 +#define _CALL_INTRINSIC_2 341 +#define _CALL_ISINSTANCE 342 +#define _CALL_KW_NON_PY 343 +#define _CALL_LEN 344 +#define _CALL_LIST_APPEND 345 +#define _CALL_METHOD_DESCRIPTOR_FAST 346 +#define _CALL_METHOD_DESCRIPTOR_FAST_INLINE 347 +#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 348 +#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE 349 +#define _CALL_METHOD_DESCRIPTOR_NOARGS 350 +#define _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE 351 +#define _CALL_METHOD_DESCRIPTOR_O 352 +#define _CALL_METHOD_DESCRIPTOR_O_INLINE 353 +#define _CALL_NON_PY_GENERAL 354 +#define _CALL_STR_1 355 +#define _CALL_TUPLE_1 356 +#define _CALL_TYPE_1 357 #define _CHECK_ATTR_CLASS 358 #define _CHECK_ATTR_METHOD_LAZY_DICT 359 #define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS 360 @@ -91,146 +91,147 @@ extern "C" { #define _CHECK_MANAGED_OBJECT_HAS_VALUES 369 #define _CHECK_METHOD_VERSION 370 #define _CHECK_METHOD_VERSION_KW 371 -#define _CHECK_PEP_523 372 -#define _CHECK_PERIODIC 373 -#define _CHECK_PERIODIC_AT_END 374 -#define _CHECK_PERIODIC_IF_NOT_YIELD_FROM 375 -#define _CHECK_RECURSION_LIMIT 376 -#define _CHECK_RECURSION_REMAINING 377 -#define _CHECK_STACK_SPACE 378 -#define _CHECK_STACK_SPACE_OPERAND 379 -#define _CHECK_VALIDITY 380 -#define _COLD_DYNAMIC_EXIT 381 -#define _COLD_EXIT 382 -#define _COMPARE_OP 383 -#define _COMPARE_OP_FLOAT 384 -#define _COMPARE_OP_INT 385 -#define _COMPARE_OP_STR 386 -#define _CONTAINS_OP 387 -#define _CONTAINS_OP_DICT 388 -#define _CONTAINS_OP_SET 389 +#define _CHECK_OBJECT 372 +#define _CHECK_PEP_523 373 +#define _CHECK_PERIODIC 374 +#define _CHECK_PERIODIC_AT_END 375 +#define _CHECK_PERIODIC_IF_NOT_YIELD_FROM 376 +#define _CHECK_RECURSION_LIMIT 377 +#define _CHECK_RECURSION_REMAINING 378 +#define _CHECK_STACK_SPACE 379 +#define _CHECK_STACK_SPACE_OPERAND 380 +#define _CHECK_VALIDITY 381 +#define _COLD_DYNAMIC_EXIT 382 +#define _COLD_EXIT 383 +#define _COMPARE_OP 384 +#define _COMPARE_OP_FLOAT 385 +#define _COMPARE_OP_INT 386 +#define _COMPARE_OP_STR 387 +#define _CONTAINS_OP 388 +#define _CONTAINS_OP_DICT 389 +#define _CONTAINS_OP_SET 390 #define _CONVERT_VALUE CONVERT_VALUE -#define _COPY 390 -#define _COPY_1 391 -#define _COPY_2 392 -#define _COPY_3 393 +#define _COPY 391 +#define _COPY_1 392 +#define _COPY_2 393 +#define _COPY_3 394 #define _COPY_FREE_VARS COPY_FREE_VARS -#define _CREATE_INIT_FRAME 394 +#define _CREATE_INIT_FRAME 395 #define _DELETE_ATTR DELETE_ATTR #define _DELETE_DEREF DELETE_DEREF #define _DELETE_FAST DELETE_FAST #define _DELETE_GLOBAL DELETE_GLOBAL #define _DELETE_NAME DELETE_NAME #define _DELETE_SUBSCR DELETE_SUBSCR -#define _DEOPT 395 -#define _DICT_MERGE 396 -#define _DICT_UPDATE 397 -#define _DO_CALL 398 -#define _DO_CALL_FUNCTION_EX 399 -#define _DO_CALL_KW 400 -#define _DYNAMIC_EXIT 401 +#define _DEOPT 396 +#define _DICT_MERGE 397 +#define _DICT_UPDATE 398 +#define _DO_CALL 399 +#define _DO_CALL_FUNCTION_EX 400 +#define _DO_CALL_KW 401 +#define _DYNAMIC_EXIT 402 #define _END_FOR END_FOR #define _END_SEND END_SEND -#define _ERROR_POP_N 402 +#define _ERROR_POP_N 403 #define _EXIT_INIT_CHECK EXIT_INIT_CHECK -#define _EXPAND_METHOD 403 -#define _EXPAND_METHOD_KW 404 -#define _FATAL_ERROR 405 +#define _EXPAND_METHOD 404 +#define _EXPAND_METHOD_KW 405 +#define _FATAL_ERROR 406 #define _FORMAT_SIMPLE FORMAT_SIMPLE #define _FORMAT_WITH_SPEC FORMAT_WITH_SPEC -#define _FOR_ITER 406 -#define _FOR_ITER_GEN_FRAME 407 -#define _FOR_ITER_TIER_TWO 408 +#define _FOR_ITER 407 +#define _FOR_ITER_GEN_FRAME 408 +#define _FOR_ITER_TIER_TWO 409 #define _GET_AITER GET_AITER #define _GET_ANEXT GET_ANEXT #define _GET_AWAITABLE GET_AWAITABLE #define _GET_ITER GET_ITER #define _GET_LEN GET_LEN -#define _GUARD_BINARY_OP_EXTEND 409 -#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS 410 -#define _GUARD_BIT_IS_SET_POP 411 -#define _GUARD_BIT_IS_SET_POP_4 412 -#define _GUARD_BIT_IS_SET_POP_5 413 -#define _GUARD_BIT_IS_SET_POP_6 414 -#define _GUARD_BIT_IS_SET_POP_7 415 -#define _GUARD_BIT_IS_UNSET_POP 416 -#define _GUARD_BIT_IS_UNSET_POP_4 417 -#define _GUARD_BIT_IS_UNSET_POP_5 418 -#define _GUARD_BIT_IS_UNSET_POP_6 419 -#define _GUARD_BIT_IS_UNSET_POP_7 420 -#define _GUARD_CALLABLE_BUILTIN_FAST 421 -#define _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS 422 -#define _GUARD_CALLABLE_BUILTIN_O 423 -#define _GUARD_CALLABLE_ISINSTANCE 424 -#define _GUARD_CALLABLE_LEN 425 -#define _GUARD_CALLABLE_LIST_APPEND 426 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST 427 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 428 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS 429 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_O 430 -#define _GUARD_CALLABLE_STR_1 431 -#define _GUARD_CALLABLE_TUPLE_1 432 -#define _GUARD_CALLABLE_TYPE_1 433 -#define _GUARD_CODE_VERSION_RETURN_GENERATOR 434 -#define _GUARD_CODE_VERSION_RETURN_VALUE 435 -#define _GUARD_CODE_VERSION_YIELD_VALUE 436 -#define _GUARD_CODE_VERSION__PUSH_FRAME 437 -#define _GUARD_DORV_NO_DICT 438 -#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT 439 -#define _GUARD_GLOBALS_VERSION 440 -#define _GUARD_IP_RETURN_GENERATOR 441 -#define _GUARD_IP_RETURN_VALUE 442 -#define _GUARD_IP_YIELD_VALUE 443 -#define _GUARD_IP__PUSH_FRAME 444 -#define _GUARD_IS_FALSE_POP 445 -#define _GUARD_IS_NONE_POP 446 -#define _GUARD_IS_NOT_NONE_POP 447 -#define _GUARD_IS_TRUE_POP 448 -#define _GUARD_KEYS_VERSION 449 -#define _GUARD_NOS_ANY_DICT 450 -#define _GUARD_NOS_COMPACT_ASCII 451 -#define _GUARD_NOS_DICT 452 -#define _GUARD_NOS_FLOAT 453 -#define _GUARD_NOS_INT 454 -#define _GUARD_NOS_LIST 455 -#define _GUARD_NOS_NOT_NULL 456 -#define _GUARD_NOS_NULL 457 -#define _GUARD_NOS_OVERFLOWED 458 -#define _GUARD_NOS_TUPLE 459 -#define _GUARD_NOS_UNICODE 460 -#define _GUARD_NOT_EXHAUSTED_LIST 461 -#define _GUARD_NOT_EXHAUSTED_RANGE 462 -#define _GUARD_NOT_EXHAUSTED_TUPLE 463 -#define _GUARD_THIRD_NULL 464 -#define _GUARD_TOS_ANY_DICT 465 -#define _GUARD_TOS_ANY_SET 466 -#define _GUARD_TOS_DICT 467 -#define _GUARD_TOS_FLOAT 468 -#define _GUARD_TOS_FROZENDICT 469 -#define _GUARD_TOS_FROZENSET 470 -#define _GUARD_TOS_INT 471 -#define _GUARD_TOS_LIST 472 -#define _GUARD_TOS_OVERFLOWED 473 -#define _GUARD_TOS_SET 474 -#define _GUARD_TOS_SLICE 475 -#define _GUARD_TOS_TUPLE 476 -#define _GUARD_TOS_UNICODE 477 -#define _GUARD_TYPE_VERSION 478 -#define _GUARD_TYPE_VERSION_LOCKED 479 -#define _HANDLE_PENDING_AND_DEOPT 480 +#define _GUARD_BINARY_OP_EXTEND 410 +#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS 411 +#define _GUARD_BIT_IS_SET_POP 412 +#define _GUARD_BIT_IS_SET_POP_4 413 +#define _GUARD_BIT_IS_SET_POP_5 414 +#define _GUARD_BIT_IS_SET_POP_6 415 +#define _GUARD_BIT_IS_SET_POP_7 416 +#define _GUARD_BIT_IS_UNSET_POP 417 +#define _GUARD_BIT_IS_UNSET_POP_4 418 +#define _GUARD_BIT_IS_UNSET_POP_5 419 +#define _GUARD_BIT_IS_UNSET_POP_6 420 +#define _GUARD_BIT_IS_UNSET_POP_7 421 +#define _GUARD_CALLABLE_BUILTIN_CLASS 422 +#define _GUARD_CALLABLE_BUILTIN_FAST 423 +#define _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS 424 +#define _GUARD_CALLABLE_BUILTIN_O 425 +#define _GUARD_CALLABLE_ISINSTANCE 426 +#define _GUARD_CALLABLE_LEN 427 +#define _GUARD_CALLABLE_LIST_APPEND 428 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST 429 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 430 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS 431 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_O 432 +#define _GUARD_CALLABLE_STR_1 433 +#define _GUARD_CALLABLE_TUPLE_1 434 +#define _GUARD_CALLABLE_TYPE_1 435 +#define _GUARD_CODE_VERSION_RETURN_GENERATOR 436 +#define _GUARD_CODE_VERSION_RETURN_VALUE 437 +#define _GUARD_CODE_VERSION_YIELD_VALUE 438 +#define _GUARD_CODE_VERSION__PUSH_FRAME 439 +#define _GUARD_DORV_NO_DICT 440 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT 441 +#define _GUARD_GLOBALS_VERSION 442 +#define _GUARD_IP_RETURN_GENERATOR 443 +#define _GUARD_IP_RETURN_VALUE 444 +#define _GUARD_IP_YIELD_VALUE 445 +#define _GUARD_IP__PUSH_FRAME 446 +#define _GUARD_IS_FALSE_POP 447 +#define _GUARD_IS_NONE_POP 448 +#define _GUARD_IS_NOT_NONE_POP 449 +#define _GUARD_IS_TRUE_POP 450 +#define _GUARD_KEYS_VERSION 451 +#define _GUARD_LOAD_SUPER_ATTR_METHOD 452 +#define _GUARD_NOS_ANY_DICT 453 +#define _GUARD_NOS_COMPACT_ASCII 454 +#define _GUARD_NOS_DICT 455 +#define _GUARD_NOS_FLOAT 456 +#define _GUARD_NOS_INT 457 +#define _GUARD_NOS_LIST 458 +#define _GUARD_NOS_NOT_NULL 459 +#define _GUARD_NOS_NULL 460 +#define _GUARD_NOS_OVERFLOWED 461 +#define _GUARD_NOS_TUPLE 462 +#define _GUARD_NOS_TYPE_VERSION 463 +#define _GUARD_NOS_UNICODE 464 +#define _GUARD_NOT_EXHAUSTED_LIST 465 +#define _GUARD_NOT_EXHAUSTED_RANGE 466 +#define _GUARD_NOT_EXHAUSTED_TUPLE 467 +#define _GUARD_THIRD_NULL 468 +#define _GUARD_TOS_ANY_DICT 469 +#define _GUARD_TOS_ANY_SET 470 +#define _GUARD_TOS_DICT 471 +#define _GUARD_TOS_FLOAT 472 +#define _GUARD_TOS_FROZENDICT 473 +#define _GUARD_TOS_FROZENSET 474 +#define _GUARD_TOS_INT 475 +#define _GUARD_TOS_LIST 476 +#define _GUARD_TOS_OVERFLOWED 477 +#define _GUARD_TOS_SET 478 +#define _GUARD_TOS_SLICE 479 +#define _GUARD_TOS_TUPLE 480 +#define _GUARD_TOS_UNICODE 481 +#define _GUARD_TYPE_VERSION 482 +#define _GUARD_TYPE_VERSION_LOCKED 483 +#define _HANDLE_PENDING_AND_DEOPT 484 #define _IMPORT_FROM IMPORT_FROM #define _IMPORT_NAME IMPORT_NAME -#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS 481 -#define _INIT_CALL_PY_EXACT_ARGS 482 -#define _INIT_CALL_PY_EXACT_ARGS_0 483 -#define _INIT_CALL_PY_EXACT_ARGS_1 484 -#define _INIT_CALL_PY_EXACT_ARGS_2 485 -#define _INIT_CALL_PY_EXACT_ARGS_3 486 -#define _INIT_CALL_PY_EXACT_ARGS_4 487 -#define _INSERT_1_LOAD_CONST_INLINE 488 -#define _INSERT_1_LOAD_CONST_INLINE_BORROW 489 -#define _INSERT_2_LOAD_CONST_INLINE_BORROW 490 -#define _INSERT_NULL 491 +#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS 485 +#define _INIT_CALL_PY_EXACT_ARGS 486 +#define _INIT_CALL_PY_EXACT_ARGS_0 487 +#define _INIT_CALL_PY_EXACT_ARGS_1 488 +#define _INIT_CALL_PY_EXACT_ARGS_2 489 +#define _INIT_CALL_PY_EXACT_ARGS_3 490 +#define _INIT_CALL_PY_EXACT_ARGS_4 491 +#define _INSERT_NULL 492 #define _INSTRUMENTED_FOR_ITER INSTRUMENTED_FOR_ITER #define _INSTRUMENTED_INSTRUCTION INSTRUMENTED_INSTRUCTION #define _INSTRUMENTED_JUMP_FORWARD INSTRUMENTED_JUMP_FORWARD @@ -240,1154 +241,1124 @@ extern "C" { #define _INSTRUMENTED_POP_JUMP_IF_NONE INSTRUMENTED_POP_JUMP_IF_NONE #define _INSTRUMENTED_POP_JUMP_IF_NOT_NONE INSTRUMENTED_POP_JUMP_IF_NOT_NONE #define _INSTRUMENTED_POP_JUMP_IF_TRUE INSTRUMENTED_POP_JUMP_IF_TRUE -#define _IS_NONE 492 -#define _IS_OP 493 -#define _ITER_CHECK_LIST 494 -#define _ITER_CHECK_RANGE 495 -#define _ITER_CHECK_TUPLE 496 -#define _ITER_JUMP_LIST 497 -#define _ITER_JUMP_RANGE 498 -#define _ITER_JUMP_TUPLE 499 -#define _ITER_NEXT_LIST 500 -#define _ITER_NEXT_LIST_TIER_TWO 501 -#define _ITER_NEXT_RANGE 502 -#define _ITER_NEXT_TUPLE 503 +#define _IS_NONE 493 +#define _IS_OP 494 +#define _ITER_CHECK_LIST 495 +#define _ITER_CHECK_RANGE 496 +#define _ITER_CHECK_TUPLE 497 +#define _ITER_JUMP_LIST 498 +#define _ITER_JUMP_RANGE 499 +#define _ITER_JUMP_TUPLE 500 +#define _ITER_NEXT_LIST 501 +#define _ITER_NEXT_LIST_TIER_TWO 502 +#define _ITER_NEXT_RANGE 503 +#define _ITER_NEXT_TUPLE 504 #define _JUMP_BACKWARD_NO_INTERRUPT JUMP_BACKWARD_NO_INTERRUPT -#define _JUMP_TO_TOP 504 +#define _JUMP_TO_TOP 505 #define _LIST_APPEND LIST_APPEND -#define _LIST_EXTEND 505 -#define _LOAD_ATTR 506 -#define _LOAD_ATTR_CLASS 507 +#define _LIST_EXTEND 506 +#define _LOAD_ATTR 507 +#define _LOAD_ATTR_CLASS 508 #define _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN -#define _LOAD_ATTR_INSTANCE_VALUE 508 -#define _LOAD_ATTR_METHOD_LAZY_DICT 509 -#define _LOAD_ATTR_METHOD_NO_DICT 510 -#define _LOAD_ATTR_METHOD_WITH_VALUES 511 -#define _LOAD_ATTR_MODULE 512 -#define _LOAD_ATTR_NONDESCRIPTOR_NO_DICT 513 -#define _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 514 -#define _LOAD_ATTR_PROPERTY_FRAME 515 -#define _LOAD_ATTR_SLOT 516 -#define _LOAD_ATTR_WITH_HINT 517 +#define _LOAD_ATTR_INSTANCE_VALUE 509 +#define _LOAD_ATTR_METHOD_LAZY_DICT 510 +#define _LOAD_ATTR_METHOD_NO_DICT 511 +#define _LOAD_ATTR_METHOD_WITH_VALUES 512 +#define _LOAD_ATTR_MODULE 513 +#define _LOAD_ATTR_NONDESCRIPTOR_NO_DICT 514 +#define _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 515 +#define _LOAD_ATTR_PROPERTY_FRAME 516 +#define _LOAD_ATTR_SLOT 517 +#define _LOAD_ATTR_WITH_HINT 518 #define _LOAD_BUILD_CLASS LOAD_BUILD_CLASS -#define _LOAD_BYTECODE 518 +#define _LOAD_BYTECODE 519 #define _LOAD_COMMON_CONSTANT LOAD_COMMON_CONSTANT #define _LOAD_CONST LOAD_CONST -#define _LOAD_CONST_INLINE 519 -#define _LOAD_CONST_INLINE_BORROW 520 -#define _LOAD_CONST_UNDER_INLINE 521 -#define _LOAD_CONST_UNDER_INLINE_BORROW 522 +#define _LOAD_CONST_INLINE 520 +#define _LOAD_CONST_INLINE_BORROW 521 #define _LOAD_DEREF LOAD_DEREF -#define _LOAD_FAST 523 -#define _LOAD_FAST_0 524 -#define _LOAD_FAST_1 525 -#define _LOAD_FAST_2 526 -#define _LOAD_FAST_3 527 -#define _LOAD_FAST_4 528 -#define _LOAD_FAST_5 529 -#define _LOAD_FAST_6 530 -#define _LOAD_FAST_7 531 +#define _LOAD_FAST 522 +#define _LOAD_FAST_0 523 +#define _LOAD_FAST_1 524 +#define _LOAD_FAST_2 525 +#define _LOAD_FAST_3 526 +#define _LOAD_FAST_4 527 +#define _LOAD_FAST_5 528 +#define _LOAD_FAST_6 529 +#define _LOAD_FAST_7 530 #define _LOAD_FAST_AND_CLEAR LOAD_FAST_AND_CLEAR -#define _LOAD_FAST_BORROW 532 -#define _LOAD_FAST_BORROW_0 533 -#define _LOAD_FAST_BORROW_1 534 -#define _LOAD_FAST_BORROW_2 535 -#define _LOAD_FAST_BORROW_3 536 -#define _LOAD_FAST_BORROW_4 537 -#define _LOAD_FAST_BORROW_5 538 -#define _LOAD_FAST_BORROW_6 539 -#define _LOAD_FAST_BORROW_7 540 +#define _LOAD_FAST_BORROW 531 +#define _LOAD_FAST_BORROW_0 532 +#define _LOAD_FAST_BORROW_1 533 +#define _LOAD_FAST_BORROW_2 534 +#define _LOAD_FAST_BORROW_3 535 +#define _LOAD_FAST_BORROW_4 536 +#define _LOAD_FAST_BORROW_5 537 +#define _LOAD_FAST_BORROW_6 538 +#define _LOAD_FAST_BORROW_7 539 #define _LOAD_FAST_CHECK LOAD_FAST_CHECK #define _LOAD_FROM_DICT_OR_DEREF LOAD_FROM_DICT_OR_DEREF #define _LOAD_FROM_DICT_OR_GLOBALS LOAD_FROM_DICT_OR_GLOBALS -#define _LOAD_GLOBAL 541 -#define _LOAD_GLOBAL_BUILTINS 542 -#define _LOAD_GLOBAL_MODULE 543 +#define _LOAD_GLOBAL 540 +#define _LOAD_GLOBAL_BUILTINS 541 +#define _LOAD_GLOBAL_MODULE 542 #define _LOAD_LOCALS LOAD_LOCALS #define _LOAD_NAME LOAD_NAME -#define _LOAD_SMALL_INT 544 -#define _LOAD_SMALL_INT_0 545 -#define _LOAD_SMALL_INT_1 546 -#define _LOAD_SMALL_INT_2 547 -#define _LOAD_SMALL_INT_3 548 -#define _LOAD_SPECIAL 549 +#define _LOAD_SMALL_INT 543 +#define _LOAD_SMALL_INT_0 544 +#define _LOAD_SMALL_INT_1 545 +#define _LOAD_SMALL_INT_2 546 +#define _LOAD_SMALL_INT_3 547 +#define _LOAD_SPECIAL 548 #define _LOAD_SUPER_ATTR_ATTR LOAD_SUPER_ATTR_ATTR -#define _LOAD_SUPER_ATTR_METHOD LOAD_SUPER_ATTR_METHOD +#define _LOAD_SUPER_ATTR_METHOD 549 #define _LOCK_OBJECT 550 #define _MAKE_CALLARGS_A_TUPLE 551 #define _MAKE_CELL MAKE_CELL -#define _MAKE_FUNCTION MAKE_FUNCTION -#define _MAKE_HEAP_SAFE 552 -#define _MAKE_WARM 553 +#define _MAKE_FUNCTION 552 +#define _MAKE_HEAP_SAFE 553 +#define _MAKE_WARM 554 #define _MAP_ADD MAP_ADD -#define _MATCH_CLASS 554 +#define _MATCH_CLASS 555 #define _MATCH_KEYS MATCH_KEYS #define _MATCH_MAPPING MATCH_MAPPING #define _MATCH_SEQUENCE MATCH_SEQUENCE -#define _MAYBE_EXPAND_METHOD 555 -#define _MAYBE_EXPAND_METHOD_KW 556 -#define _MONITOR_CALL 557 -#define _MONITOR_CALL_KW 558 -#define _MONITOR_JUMP_BACKWARD 559 -#define _MONITOR_RESUME 560 +#define _MAYBE_EXPAND_METHOD 556 +#define _MAYBE_EXPAND_METHOD_KW 557 +#define _MONITOR_CALL 558 +#define _MONITOR_CALL_KW 559 +#define _MONITOR_JUMP_BACKWARD 560 +#define _MONITOR_RESUME 561 #define _NOP NOP -#define _POP_CALL 561 -#define _POP_CALL_LOAD_CONST_INLINE_BORROW 562 -#define _POP_CALL_ONE 563 -#define _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW 564 -#define _POP_CALL_TWO 565 -#define _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW 566 #define _POP_EXCEPT POP_EXCEPT #define _POP_ITER POP_ITER -#define _POP_JUMP_IF_FALSE 567 -#define _POP_JUMP_IF_TRUE 568 +#define _POP_JUMP_IF_FALSE 562 +#define _POP_JUMP_IF_TRUE 563 #define _POP_TOP POP_TOP -#define _POP_TOP_FLOAT 569 -#define _POP_TOP_INT 570 -#define _POP_TOP_LOAD_CONST_INLINE 571 -#define _POP_TOP_LOAD_CONST_INLINE_BORROW 572 -#define _POP_TOP_NOP 573 -#define _POP_TOP_UNICODE 574 -#define _POP_TWO 575 -#define _POP_TWO_LOAD_CONST_INLINE_BORROW 576 +#define _POP_TOP_FLOAT 564 +#define _POP_TOP_INT 565 +#define _POP_TOP_NOP 566 +#define _POP_TOP_OPARG 567 +#define _POP_TOP_UNICODE 568 #define _PUSH_EXC_INFO PUSH_EXC_INFO -#define _PUSH_FRAME 577 +#define _PUSH_FRAME 569 #define _PUSH_NULL PUSH_NULL -#define _PUSH_NULL_CONDITIONAL 578 -#define _PY_FRAME_EX 579 -#define _PY_FRAME_GENERAL 580 -#define _PY_FRAME_KW 581 -#define _RECORD_3OS_GEN_FUNC 582 -#define _RECORD_4OS 583 -#define _RECORD_BOUND_METHOD 584 -#define _RECORD_CALLABLE 585 -#define _RECORD_CODE 586 -#define _RECORD_NOS 587 -#define _RECORD_NOS_GEN_FUNC 588 -#define _RECORD_TOS 589 -#define _RECORD_TOS_TYPE 590 -#define _REPLACE_WITH_TRUE 591 -#define _RESUME_CHECK 592 +#define _PUSH_NULL_CONDITIONAL 570 +#define _PY_FRAME_EX 571 +#define _PY_FRAME_GENERAL 572 +#define _PY_FRAME_KW 573 +#define _RECORD_3OS_GEN_FUNC 574 +#define _RECORD_4OS 575 +#define _RECORD_BOUND_METHOD 576 +#define _RECORD_CALLABLE 577 +#define _RECORD_CODE 578 +#define _RECORD_NOS 579 +#define _RECORD_NOS_GEN_FUNC 580 +#define _RECORD_TOS 581 +#define _RECORD_TOS_TYPE 582 +#define _REPLACE_WITH_TRUE 583 +#define _RESUME_CHECK 584 #define _RETURN_GENERATOR RETURN_GENERATOR -#define _RETURN_VALUE 593 -#define _SAVE_RETURN_OFFSET 594 -#define _SEND 595 -#define _SEND_GEN_FRAME 596 +#define _RETURN_VALUE 585 +#define _SAVE_RETURN_OFFSET 586 +#define _SEND 587 +#define _SEND_GEN_FRAME 588 #define _SETUP_ANNOTATIONS SETUP_ANNOTATIONS #define _SET_ADD SET_ADD #define _SET_FUNCTION_ATTRIBUTE SET_FUNCTION_ATTRIBUTE -#define _SET_UPDATE 597 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW 598 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW 599 -#define _SPILL_OR_RELOAD 600 -#define _START_EXECUTOR 601 -#define _STORE_ATTR 602 -#define _STORE_ATTR_INSTANCE_VALUE 603 -#define _STORE_ATTR_SLOT 604 -#define _STORE_ATTR_WITH_HINT 605 +#define _SET_UPDATE 589 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW 590 +#define _SPILL_OR_RELOAD 591 +#define _START_EXECUTOR 592 +#define _STORE_ATTR 593 +#define _STORE_ATTR_INSTANCE_VALUE 594 +#define _STORE_ATTR_SLOT 595 +#define _STORE_ATTR_WITH_HINT 596 #define _STORE_DEREF STORE_DEREF #define _STORE_GLOBAL STORE_GLOBAL #define _STORE_NAME STORE_NAME -#define _STORE_SLICE 606 -#define _STORE_SUBSCR 607 -#define _STORE_SUBSCR_DICT 608 -#define _STORE_SUBSCR_DICT_KNOWN_HASH 609 -#define _STORE_SUBSCR_LIST_INT 610 -#define _SWAP 611 -#define _SWAP_2 612 -#define _SWAP_3 613 -#define _SWAP_FAST 614 -#define _SWAP_FAST_0 615 -#define _SWAP_FAST_1 616 -#define _SWAP_FAST_2 617 -#define _SWAP_FAST_3 618 -#define _SWAP_FAST_4 619 -#define _SWAP_FAST_5 620 -#define _SWAP_FAST_6 621 -#define _SWAP_FAST_7 622 -#define _TIER2_RESUME_CHECK 623 -#define _TO_BOOL 624 +#define _STORE_SLICE 597 +#define _STORE_SUBSCR 598 +#define _STORE_SUBSCR_DICT 599 +#define _STORE_SUBSCR_DICT_KNOWN_HASH 600 +#define _STORE_SUBSCR_LIST_INT 601 +#define _SWAP 602 +#define _SWAP_2 603 +#define _SWAP_3 604 +#define _SWAP_FAST 605 +#define _SWAP_FAST_0 606 +#define _SWAP_FAST_1 607 +#define _SWAP_FAST_2 608 +#define _SWAP_FAST_3 609 +#define _SWAP_FAST_4 610 +#define _SWAP_FAST_5 611 +#define _SWAP_FAST_6 612 +#define _SWAP_FAST_7 613 +#define _TIER2_RESUME_CHECK 614 +#define _TO_BOOL 615 #define _TO_BOOL_BOOL TO_BOOL_BOOL -#define _TO_BOOL_INT 625 -#define _TO_BOOL_LIST 626 +#define _TO_BOOL_INT 616 +#define _TO_BOOL_LIST 617 #define _TO_BOOL_NONE TO_BOOL_NONE -#define _TO_BOOL_STR 627 +#define _TO_BOOL_STR 618 #define _TRACE_RECORD TRACE_RECORD -#define _UNARY_INVERT 628 -#define _UNARY_NEGATIVE 629 -#define _UNARY_NEGATIVE_FLOAT_INPLACE 630 +#define _UNARY_INVERT 619 +#define _UNARY_NEGATIVE 620 +#define _UNARY_NEGATIVE_FLOAT_INPLACE 621 #define _UNARY_NOT UNARY_NOT #define _UNPACK_EX UNPACK_EX -#define _UNPACK_SEQUENCE 631 -#define _UNPACK_SEQUENCE_LIST 632 -#define _UNPACK_SEQUENCE_TUPLE 633 -#define _UNPACK_SEQUENCE_TWO_TUPLE 634 -#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE 635 -#define _UNPACK_SEQUENCE_UNIQUE_TUPLE 636 -#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE 637 +#define _UNPACK_SEQUENCE 622 +#define _UNPACK_SEQUENCE_LIST 623 +#define _UNPACK_SEQUENCE_TUPLE 624 +#define _UNPACK_SEQUENCE_TWO_TUPLE 625 +#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE 626 +#define _UNPACK_SEQUENCE_UNIQUE_TUPLE 627 +#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE 628 #define _WITH_EXCEPT_START WITH_EXCEPT_START -#define _YIELD_VALUE 638 -#define MAX_UOP_ID 638 -#define _BINARY_OP_r23 639 -#define _BINARY_OP_ADD_FLOAT_r03 640 -#define _BINARY_OP_ADD_FLOAT_r13 641 -#define _BINARY_OP_ADD_FLOAT_r23 642 -#define _BINARY_OP_ADD_FLOAT_INPLACE_r03 643 -#define _BINARY_OP_ADD_FLOAT_INPLACE_r13 644 -#define _BINARY_OP_ADD_FLOAT_INPLACE_r23 645 -#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r03 646 -#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r13 647 -#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r23 648 -#define _BINARY_OP_ADD_INT_r03 649 -#define _BINARY_OP_ADD_INT_r13 650 -#define _BINARY_OP_ADD_INT_r23 651 -#define _BINARY_OP_ADD_INT_INPLACE_r03 652 -#define _BINARY_OP_ADD_INT_INPLACE_r13 653 -#define _BINARY_OP_ADD_INT_INPLACE_r23 654 -#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r03 655 -#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r13 656 -#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r23 657 -#define _BINARY_OP_ADD_UNICODE_r03 658 -#define _BINARY_OP_ADD_UNICODE_r13 659 -#define _BINARY_OP_ADD_UNICODE_r23 660 -#define _BINARY_OP_EXTEND_r23 661 -#define _BINARY_OP_INPLACE_ADD_UNICODE_r21 662 -#define _BINARY_OP_MULTIPLY_FLOAT_r03 663 -#define _BINARY_OP_MULTIPLY_FLOAT_r13 664 -#define _BINARY_OP_MULTIPLY_FLOAT_r23 665 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r03 666 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r13 667 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r23 668 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r03 669 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r13 670 -#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r23 671 -#define _BINARY_OP_MULTIPLY_INT_r03 672 -#define _BINARY_OP_MULTIPLY_INT_r13 673 -#define _BINARY_OP_MULTIPLY_INT_r23 674 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_r03 675 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_r13 676 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_r23 677 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r03 678 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r13 679 -#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r23 680 -#define _BINARY_OP_SUBSCR_CHECK_FUNC_r23 681 -#define _BINARY_OP_SUBSCR_DICT_r23 682 -#define _BINARY_OP_SUBSCR_DICT_KNOWN_HASH_r23 683 -#define _BINARY_OP_SUBSCR_INIT_CALL_r01 684 -#define _BINARY_OP_SUBSCR_INIT_CALL_r11 685 -#define _BINARY_OP_SUBSCR_INIT_CALL_r21 686 -#define _BINARY_OP_SUBSCR_INIT_CALL_r31 687 -#define _BINARY_OP_SUBSCR_LIST_INT_r23 688 -#define _BINARY_OP_SUBSCR_LIST_SLICE_r23 689 -#define _BINARY_OP_SUBSCR_STR_INT_r23 690 -#define _BINARY_OP_SUBSCR_TUPLE_INT_r03 691 -#define _BINARY_OP_SUBSCR_TUPLE_INT_r13 692 -#define _BINARY_OP_SUBSCR_TUPLE_INT_r23 693 -#define _BINARY_OP_SUBSCR_USTR_INT_r23 694 -#define _BINARY_OP_SUBTRACT_FLOAT_r03 695 -#define _BINARY_OP_SUBTRACT_FLOAT_r13 696 -#define _BINARY_OP_SUBTRACT_FLOAT_r23 697 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r03 698 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r13 699 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r23 700 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r03 701 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r13 702 -#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r23 703 -#define _BINARY_OP_SUBTRACT_INT_r03 704 -#define _BINARY_OP_SUBTRACT_INT_r13 705 -#define _BINARY_OP_SUBTRACT_INT_r23 706 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_r03 707 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_r13 708 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_r23 709 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r03 710 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r13 711 -#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r23 712 -#define _BINARY_SLICE_r31 713 -#define _BUILD_INTERPOLATION_r01 714 -#define _BUILD_LIST_r01 715 -#define _BUILD_MAP_r01 716 -#define _BUILD_SET_r01 717 -#define _BUILD_SLICE_r01 718 -#define _BUILD_STRING_r01 719 -#define _BUILD_TEMPLATE_r21 720 -#define _BUILD_TUPLE_r01 721 -#define _CALL_BUILTIN_CLASS_r01 722 -#define _CALL_BUILTIN_FAST_r01 723 -#define _CALL_BUILTIN_FAST_WITH_KEYWORDS_r01 724 -#define _CALL_BUILTIN_O_r03 725 -#define _CALL_FUNCTION_EX_NON_PY_GENERAL_r31 726 -#define _CALL_INTRINSIC_1_r12 727 -#define _CALL_INTRINSIC_2_r23 728 -#define _CALL_ISINSTANCE_r31 729 -#define _CALL_KW_NON_PY_r11 730 -#define _CALL_LEN_r33 731 -#define _CALL_LIST_APPEND_r03 732 -#define _CALL_LIST_APPEND_r13 733 -#define _CALL_LIST_APPEND_r23 734 -#define _CALL_LIST_APPEND_r33 735 -#define _CALL_METHOD_DESCRIPTOR_FAST_r01 736 -#define _CALL_METHOD_DESCRIPTOR_FAST_INLINE_r01 737 -#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r01 738 -#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r01 739 -#define _CALL_METHOD_DESCRIPTOR_NOARGS_r01 740 -#define _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r01 741 -#define _CALL_METHOD_DESCRIPTOR_O_r03 742 -#define _CALL_METHOD_DESCRIPTOR_O_INLINE_r03 743 -#define _CALL_NON_PY_GENERAL_r01 744 -#define _CALL_STR_1_r32 745 -#define _CALL_TUPLE_1_r32 746 -#define _CALL_TYPE_1_r02 747 -#define _CALL_TYPE_1_r12 748 -#define _CALL_TYPE_1_r22 749 -#define _CALL_TYPE_1_r32 750 -#define _CHECK_AND_ALLOCATE_OBJECT_r00 751 -#define _CHECK_ATTR_CLASS_r01 752 -#define _CHECK_ATTR_CLASS_r11 753 -#define _CHECK_ATTR_CLASS_r22 754 -#define _CHECK_ATTR_CLASS_r33 755 -#define _CHECK_ATTR_METHOD_LAZY_DICT_r01 756 -#define _CHECK_ATTR_METHOD_LAZY_DICT_r11 757 -#define _CHECK_ATTR_METHOD_LAZY_DICT_r22 758 -#define _CHECK_ATTR_METHOD_LAZY_DICT_r33 759 -#define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS_r00 760 -#define _CHECK_EG_MATCH_r22 761 -#define _CHECK_EXC_MATCH_r22 762 -#define _CHECK_FUNCTION_EXACT_ARGS_r00 763 -#define _CHECK_FUNCTION_VERSION_r00 764 -#define _CHECK_FUNCTION_VERSION_INLINE_r00 765 -#define _CHECK_FUNCTION_VERSION_INLINE_r11 766 -#define _CHECK_FUNCTION_VERSION_INLINE_r22 767 -#define _CHECK_FUNCTION_VERSION_INLINE_r33 768 -#define _CHECK_FUNCTION_VERSION_KW_r11 769 -#define _CHECK_IS_NOT_PY_CALLABLE_r00 770 -#define _CHECK_IS_NOT_PY_CALLABLE_EX_r03 771 -#define _CHECK_IS_NOT_PY_CALLABLE_EX_r13 772 -#define _CHECK_IS_NOT_PY_CALLABLE_EX_r23 773 -#define _CHECK_IS_NOT_PY_CALLABLE_EX_r33 774 -#define _CHECK_IS_NOT_PY_CALLABLE_KW_r11 775 -#define _CHECK_IS_PY_CALLABLE_EX_r03 776 -#define _CHECK_IS_PY_CALLABLE_EX_r13 777 -#define _CHECK_IS_PY_CALLABLE_EX_r23 778 -#define _CHECK_IS_PY_CALLABLE_EX_r33 779 -#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r01 780 -#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r11 781 -#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r22 782 -#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r33 783 -#define _CHECK_METHOD_VERSION_r00 784 -#define _CHECK_METHOD_VERSION_KW_r11 785 -#define _CHECK_PEP_523_r00 786 -#define _CHECK_PEP_523_r11 787 -#define _CHECK_PEP_523_r22 788 -#define _CHECK_PEP_523_r33 789 -#define _CHECK_PERIODIC_r00 790 -#define _CHECK_PERIODIC_AT_END_r00 791 -#define _CHECK_PERIODIC_IF_NOT_YIELD_FROM_r00 792 -#define _CHECK_RECURSION_LIMIT_r00 793 -#define _CHECK_RECURSION_LIMIT_r11 794 -#define _CHECK_RECURSION_LIMIT_r22 795 -#define _CHECK_RECURSION_LIMIT_r33 796 -#define _CHECK_RECURSION_REMAINING_r00 797 -#define _CHECK_RECURSION_REMAINING_r11 798 -#define _CHECK_RECURSION_REMAINING_r22 799 -#define _CHECK_RECURSION_REMAINING_r33 800 -#define _CHECK_STACK_SPACE_r00 801 -#define _CHECK_STACK_SPACE_OPERAND_r00 802 -#define _CHECK_STACK_SPACE_OPERAND_r11 803 -#define _CHECK_STACK_SPACE_OPERAND_r22 804 -#define _CHECK_STACK_SPACE_OPERAND_r33 805 -#define _CHECK_VALIDITY_r00 806 -#define _CHECK_VALIDITY_r11 807 -#define _CHECK_VALIDITY_r22 808 -#define _CHECK_VALIDITY_r33 809 -#define _COLD_DYNAMIC_EXIT_r00 810 -#define _COLD_EXIT_r00 811 -#define _COMPARE_OP_r21 812 -#define _COMPARE_OP_FLOAT_r03 813 -#define _COMPARE_OP_FLOAT_r13 814 -#define _COMPARE_OP_FLOAT_r23 815 -#define _COMPARE_OP_INT_r23 816 -#define _COMPARE_OP_STR_r23 817 -#define _CONTAINS_OP_r23 818 -#define _CONTAINS_OP_DICT_r23 819 -#define _CONTAINS_OP_SET_r23 820 -#define _CONVERT_VALUE_r11 821 -#define _COPY_r01 822 -#define _COPY_1_r02 823 -#define _COPY_1_r12 824 -#define _COPY_1_r23 825 -#define _COPY_2_r03 826 -#define _COPY_2_r13 827 -#define _COPY_2_r23 828 -#define _COPY_3_r03 829 -#define _COPY_3_r13 830 -#define _COPY_3_r23 831 -#define _COPY_3_r33 832 -#define _COPY_FREE_VARS_r00 833 -#define _COPY_FREE_VARS_r11 834 -#define _COPY_FREE_VARS_r22 835 -#define _COPY_FREE_VARS_r33 836 -#define _CREATE_INIT_FRAME_r01 837 -#define _DELETE_ATTR_r10 838 -#define _DELETE_DEREF_r00 839 -#define _DELETE_FAST_r00 840 -#define _DELETE_GLOBAL_r00 841 -#define _DELETE_NAME_r00 842 -#define _DELETE_SUBSCR_r20 843 -#define _DEOPT_r00 844 -#define _DEOPT_r10 845 -#define _DEOPT_r20 846 -#define _DEOPT_r30 847 -#define _DICT_MERGE_r11 848 -#define _DICT_UPDATE_r11 849 -#define _DO_CALL_r01 850 -#define _DO_CALL_FUNCTION_EX_r31 851 -#define _DO_CALL_KW_r11 852 -#define _DYNAMIC_EXIT_r00 853 -#define _DYNAMIC_EXIT_r10 854 -#define _DYNAMIC_EXIT_r20 855 -#define _DYNAMIC_EXIT_r30 856 -#define _END_FOR_r10 857 -#define _END_SEND_r31 858 -#define _ERROR_POP_N_r00 859 -#define _EXIT_INIT_CHECK_r10 860 -#define _EXIT_TRACE_r00 861 -#define _EXIT_TRACE_r10 862 -#define _EXIT_TRACE_r20 863 -#define _EXIT_TRACE_r30 864 -#define _EXPAND_METHOD_r00 865 -#define _EXPAND_METHOD_KW_r11 866 -#define _FATAL_ERROR_r00 867 -#define _FATAL_ERROR_r11 868 -#define _FATAL_ERROR_r22 869 -#define _FATAL_ERROR_r33 870 -#define _FORMAT_SIMPLE_r11 871 -#define _FORMAT_WITH_SPEC_r21 872 -#define _FOR_ITER_r23 873 -#define _FOR_ITER_GEN_FRAME_r03 874 -#define _FOR_ITER_GEN_FRAME_r13 875 -#define _FOR_ITER_GEN_FRAME_r23 876 -#define _FOR_ITER_TIER_TWO_r23 877 -#define _GET_AITER_r11 878 -#define _GET_ANEXT_r12 879 -#define _GET_AWAITABLE_r11 880 -#define _GET_ITER_r12 881 -#define _GET_LEN_r12 882 -#define _GUARD_BINARY_OP_EXTEND_r22 883 -#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r02 884 -#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r12 885 -#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r22 886 -#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r33 887 -#define _GUARD_BIT_IS_SET_POP_r00 888 -#define _GUARD_BIT_IS_SET_POP_r10 889 -#define _GUARD_BIT_IS_SET_POP_r21 890 -#define _GUARD_BIT_IS_SET_POP_r32 891 -#define _GUARD_BIT_IS_SET_POP_4_r00 892 -#define _GUARD_BIT_IS_SET_POP_4_r10 893 -#define _GUARD_BIT_IS_SET_POP_4_r21 894 -#define _GUARD_BIT_IS_SET_POP_4_r32 895 -#define _GUARD_BIT_IS_SET_POP_5_r00 896 -#define _GUARD_BIT_IS_SET_POP_5_r10 897 -#define _GUARD_BIT_IS_SET_POP_5_r21 898 -#define _GUARD_BIT_IS_SET_POP_5_r32 899 -#define _GUARD_BIT_IS_SET_POP_6_r00 900 -#define _GUARD_BIT_IS_SET_POP_6_r10 901 -#define _GUARD_BIT_IS_SET_POP_6_r21 902 -#define _GUARD_BIT_IS_SET_POP_6_r32 903 -#define _GUARD_BIT_IS_SET_POP_7_r00 904 -#define _GUARD_BIT_IS_SET_POP_7_r10 905 -#define _GUARD_BIT_IS_SET_POP_7_r21 906 -#define _GUARD_BIT_IS_SET_POP_7_r32 907 -#define _GUARD_BIT_IS_UNSET_POP_r00 908 -#define _GUARD_BIT_IS_UNSET_POP_r10 909 -#define _GUARD_BIT_IS_UNSET_POP_r21 910 -#define _GUARD_BIT_IS_UNSET_POP_r32 911 -#define _GUARD_BIT_IS_UNSET_POP_4_r00 912 -#define _GUARD_BIT_IS_UNSET_POP_4_r10 913 -#define _GUARD_BIT_IS_UNSET_POP_4_r21 914 -#define _GUARD_BIT_IS_UNSET_POP_4_r32 915 -#define _GUARD_BIT_IS_UNSET_POP_5_r00 916 -#define _GUARD_BIT_IS_UNSET_POP_5_r10 917 -#define _GUARD_BIT_IS_UNSET_POP_5_r21 918 -#define _GUARD_BIT_IS_UNSET_POP_5_r32 919 -#define _GUARD_BIT_IS_UNSET_POP_6_r00 920 -#define _GUARD_BIT_IS_UNSET_POP_6_r10 921 -#define _GUARD_BIT_IS_UNSET_POP_6_r21 922 -#define _GUARD_BIT_IS_UNSET_POP_6_r32 923 -#define _GUARD_BIT_IS_UNSET_POP_7_r00 924 -#define _GUARD_BIT_IS_UNSET_POP_7_r10 925 -#define _GUARD_BIT_IS_UNSET_POP_7_r21 926 -#define _GUARD_BIT_IS_UNSET_POP_7_r32 927 -#define _GUARD_CALLABLE_BUILTIN_FAST_r00 928 -#define _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS_r00 929 -#define _GUARD_CALLABLE_BUILTIN_O_r00 930 -#define _GUARD_CALLABLE_ISINSTANCE_r03 931 -#define _GUARD_CALLABLE_ISINSTANCE_r13 932 -#define _GUARD_CALLABLE_ISINSTANCE_r23 933 -#define _GUARD_CALLABLE_ISINSTANCE_r33 934 -#define _GUARD_CALLABLE_LEN_r03 935 -#define _GUARD_CALLABLE_LEN_r13 936 -#define _GUARD_CALLABLE_LEN_r23 937 -#define _GUARD_CALLABLE_LEN_r33 938 -#define _GUARD_CALLABLE_LIST_APPEND_r03 939 -#define _GUARD_CALLABLE_LIST_APPEND_r13 940 -#define _GUARD_CALLABLE_LIST_APPEND_r23 941 -#define _GUARD_CALLABLE_LIST_APPEND_r33 942 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_r00 943 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00 944 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS_r00 945 -#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_O_r00 946 -#define _GUARD_CALLABLE_STR_1_r03 947 -#define _GUARD_CALLABLE_STR_1_r13 948 -#define _GUARD_CALLABLE_STR_1_r23 949 -#define _GUARD_CALLABLE_STR_1_r33 950 -#define _GUARD_CALLABLE_TUPLE_1_r03 951 -#define _GUARD_CALLABLE_TUPLE_1_r13 952 -#define _GUARD_CALLABLE_TUPLE_1_r23 953 -#define _GUARD_CALLABLE_TUPLE_1_r33 954 -#define _GUARD_CALLABLE_TYPE_1_r03 955 -#define _GUARD_CALLABLE_TYPE_1_r13 956 -#define _GUARD_CALLABLE_TYPE_1_r23 957 -#define _GUARD_CALLABLE_TYPE_1_r33 958 -#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r00 959 -#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r11 960 -#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r22 961 -#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r33 962 -#define _GUARD_CODE_VERSION_RETURN_VALUE_r00 963 -#define _GUARD_CODE_VERSION_RETURN_VALUE_r11 964 -#define _GUARD_CODE_VERSION_RETURN_VALUE_r22 965 -#define _GUARD_CODE_VERSION_RETURN_VALUE_r33 966 -#define _GUARD_CODE_VERSION_YIELD_VALUE_r00 967 -#define _GUARD_CODE_VERSION_YIELD_VALUE_r11 968 -#define _GUARD_CODE_VERSION_YIELD_VALUE_r22 969 -#define _GUARD_CODE_VERSION_YIELD_VALUE_r33 970 -#define _GUARD_CODE_VERSION__PUSH_FRAME_r00 971 -#define _GUARD_CODE_VERSION__PUSH_FRAME_r11 972 -#define _GUARD_CODE_VERSION__PUSH_FRAME_r22 973 -#define _GUARD_CODE_VERSION__PUSH_FRAME_r33 974 -#define _GUARD_DORV_NO_DICT_r01 975 -#define _GUARD_DORV_NO_DICT_r11 976 -#define _GUARD_DORV_NO_DICT_r22 977 -#define _GUARD_DORV_NO_DICT_r33 978 -#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r01 979 -#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r11 980 -#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r22 981 -#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r33 982 -#define _GUARD_GLOBALS_VERSION_r00 983 -#define _GUARD_GLOBALS_VERSION_r11 984 -#define _GUARD_GLOBALS_VERSION_r22 985 -#define _GUARD_GLOBALS_VERSION_r33 986 -#define _GUARD_IP_RETURN_GENERATOR_r00 987 -#define _GUARD_IP_RETURN_GENERATOR_r11 988 -#define _GUARD_IP_RETURN_GENERATOR_r22 989 -#define _GUARD_IP_RETURN_GENERATOR_r33 990 -#define _GUARD_IP_RETURN_VALUE_r00 991 -#define _GUARD_IP_RETURN_VALUE_r11 992 -#define _GUARD_IP_RETURN_VALUE_r22 993 -#define _GUARD_IP_RETURN_VALUE_r33 994 -#define _GUARD_IP_YIELD_VALUE_r00 995 -#define _GUARD_IP_YIELD_VALUE_r11 996 -#define _GUARD_IP_YIELD_VALUE_r22 997 -#define _GUARD_IP_YIELD_VALUE_r33 998 -#define _GUARD_IP__PUSH_FRAME_r00 999 -#define _GUARD_IP__PUSH_FRAME_r11 1000 -#define _GUARD_IP__PUSH_FRAME_r22 1001 -#define _GUARD_IP__PUSH_FRAME_r33 1002 -#define _GUARD_IS_FALSE_POP_r00 1003 -#define _GUARD_IS_FALSE_POP_r10 1004 -#define _GUARD_IS_FALSE_POP_r21 1005 -#define _GUARD_IS_FALSE_POP_r32 1006 -#define _GUARD_IS_NONE_POP_r00 1007 -#define _GUARD_IS_NONE_POP_r10 1008 -#define _GUARD_IS_NONE_POP_r21 1009 -#define _GUARD_IS_NONE_POP_r32 1010 -#define _GUARD_IS_NOT_NONE_POP_r10 1011 -#define _GUARD_IS_TRUE_POP_r00 1012 -#define _GUARD_IS_TRUE_POP_r10 1013 -#define _GUARD_IS_TRUE_POP_r21 1014 -#define _GUARD_IS_TRUE_POP_r32 1015 -#define _GUARD_KEYS_VERSION_r01 1016 -#define _GUARD_KEYS_VERSION_r11 1017 -#define _GUARD_KEYS_VERSION_r22 1018 -#define _GUARD_KEYS_VERSION_r33 1019 -#define _GUARD_NOS_ANY_DICT_r02 1020 -#define _GUARD_NOS_ANY_DICT_r12 1021 -#define _GUARD_NOS_ANY_DICT_r22 1022 -#define _GUARD_NOS_ANY_DICT_r33 1023 -#define _GUARD_NOS_COMPACT_ASCII_r02 1024 -#define _GUARD_NOS_COMPACT_ASCII_r12 1025 -#define _GUARD_NOS_COMPACT_ASCII_r22 1026 -#define _GUARD_NOS_COMPACT_ASCII_r33 1027 -#define _GUARD_NOS_DICT_r02 1028 -#define _GUARD_NOS_DICT_r12 1029 -#define _GUARD_NOS_DICT_r22 1030 -#define _GUARD_NOS_DICT_r33 1031 -#define _GUARD_NOS_FLOAT_r02 1032 -#define _GUARD_NOS_FLOAT_r12 1033 -#define _GUARD_NOS_FLOAT_r22 1034 -#define _GUARD_NOS_FLOAT_r33 1035 -#define _GUARD_NOS_INT_r02 1036 -#define _GUARD_NOS_INT_r12 1037 -#define _GUARD_NOS_INT_r22 1038 -#define _GUARD_NOS_INT_r33 1039 -#define _GUARD_NOS_LIST_r02 1040 -#define _GUARD_NOS_LIST_r12 1041 -#define _GUARD_NOS_LIST_r22 1042 -#define _GUARD_NOS_LIST_r33 1043 -#define _GUARD_NOS_NOT_NULL_r02 1044 -#define _GUARD_NOS_NOT_NULL_r12 1045 -#define _GUARD_NOS_NOT_NULL_r22 1046 -#define _GUARD_NOS_NOT_NULL_r33 1047 -#define _GUARD_NOS_NULL_r02 1048 -#define _GUARD_NOS_NULL_r12 1049 -#define _GUARD_NOS_NULL_r22 1050 -#define _GUARD_NOS_NULL_r33 1051 -#define _GUARD_NOS_OVERFLOWED_r02 1052 -#define _GUARD_NOS_OVERFLOWED_r12 1053 -#define _GUARD_NOS_OVERFLOWED_r22 1054 -#define _GUARD_NOS_OVERFLOWED_r33 1055 -#define _GUARD_NOS_TUPLE_r02 1056 -#define _GUARD_NOS_TUPLE_r12 1057 -#define _GUARD_NOS_TUPLE_r22 1058 -#define _GUARD_NOS_TUPLE_r33 1059 -#define _GUARD_NOS_UNICODE_r02 1060 -#define _GUARD_NOS_UNICODE_r12 1061 -#define _GUARD_NOS_UNICODE_r22 1062 -#define _GUARD_NOS_UNICODE_r33 1063 -#define _GUARD_NOT_EXHAUSTED_LIST_r02 1064 -#define _GUARD_NOT_EXHAUSTED_LIST_r12 1065 -#define _GUARD_NOT_EXHAUSTED_LIST_r22 1066 -#define _GUARD_NOT_EXHAUSTED_LIST_r33 1067 -#define _GUARD_NOT_EXHAUSTED_RANGE_r02 1068 -#define _GUARD_NOT_EXHAUSTED_RANGE_r12 1069 -#define _GUARD_NOT_EXHAUSTED_RANGE_r22 1070 -#define _GUARD_NOT_EXHAUSTED_RANGE_r33 1071 -#define _GUARD_NOT_EXHAUSTED_TUPLE_r02 1072 -#define _GUARD_NOT_EXHAUSTED_TUPLE_r12 1073 -#define _GUARD_NOT_EXHAUSTED_TUPLE_r22 1074 -#define _GUARD_NOT_EXHAUSTED_TUPLE_r33 1075 -#define _GUARD_THIRD_NULL_r03 1076 -#define _GUARD_THIRD_NULL_r13 1077 -#define _GUARD_THIRD_NULL_r23 1078 -#define _GUARD_THIRD_NULL_r33 1079 -#define _GUARD_TOS_ANY_DICT_r01 1080 -#define _GUARD_TOS_ANY_DICT_r11 1081 -#define _GUARD_TOS_ANY_DICT_r22 1082 -#define _GUARD_TOS_ANY_DICT_r33 1083 -#define _GUARD_TOS_ANY_SET_r01 1084 -#define _GUARD_TOS_ANY_SET_r11 1085 -#define _GUARD_TOS_ANY_SET_r22 1086 -#define _GUARD_TOS_ANY_SET_r33 1087 -#define _GUARD_TOS_DICT_r01 1088 -#define _GUARD_TOS_DICT_r11 1089 -#define _GUARD_TOS_DICT_r22 1090 -#define _GUARD_TOS_DICT_r33 1091 -#define _GUARD_TOS_FLOAT_r01 1092 -#define _GUARD_TOS_FLOAT_r11 1093 -#define _GUARD_TOS_FLOAT_r22 1094 -#define _GUARD_TOS_FLOAT_r33 1095 -#define _GUARD_TOS_FROZENDICT_r01 1096 -#define _GUARD_TOS_FROZENDICT_r11 1097 -#define _GUARD_TOS_FROZENDICT_r22 1098 -#define _GUARD_TOS_FROZENDICT_r33 1099 -#define _GUARD_TOS_FROZENSET_r01 1100 -#define _GUARD_TOS_FROZENSET_r11 1101 -#define _GUARD_TOS_FROZENSET_r22 1102 -#define _GUARD_TOS_FROZENSET_r33 1103 -#define _GUARD_TOS_INT_r01 1104 -#define _GUARD_TOS_INT_r11 1105 -#define _GUARD_TOS_INT_r22 1106 -#define _GUARD_TOS_INT_r33 1107 -#define _GUARD_TOS_LIST_r01 1108 -#define _GUARD_TOS_LIST_r11 1109 -#define _GUARD_TOS_LIST_r22 1110 -#define _GUARD_TOS_LIST_r33 1111 -#define _GUARD_TOS_OVERFLOWED_r01 1112 -#define _GUARD_TOS_OVERFLOWED_r11 1113 -#define _GUARD_TOS_OVERFLOWED_r22 1114 -#define _GUARD_TOS_OVERFLOWED_r33 1115 -#define _GUARD_TOS_SET_r01 1116 -#define _GUARD_TOS_SET_r11 1117 -#define _GUARD_TOS_SET_r22 1118 -#define _GUARD_TOS_SET_r33 1119 -#define _GUARD_TOS_SLICE_r01 1120 -#define _GUARD_TOS_SLICE_r11 1121 -#define _GUARD_TOS_SLICE_r22 1122 -#define _GUARD_TOS_SLICE_r33 1123 -#define _GUARD_TOS_TUPLE_r01 1124 -#define _GUARD_TOS_TUPLE_r11 1125 -#define _GUARD_TOS_TUPLE_r22 1126 -#define _GUARD_TOS_TUPLE_r33 1127 -#define _GUARD_TOS_UNICODE_r01 1128 -#define _GUARD_TOS_UNICODE_r11 1129 -#define _GUARD_TOS_UNICODE_r22 1130 -#define _GUARD_TOS_UNICODE_r33 1131 -#define _GUARD_TYPE_VERSION_r01 1132 -#define _GUARD_TYPE_VERSION_r11 1133 -#define _GUARD_TYPE_VERSION_r22 1134 -#define _GUARD_TYPE_VERSION_r33 1135 -#define _GUARD_TYPE_VERSION_LOCKED_r01 1136 -#define _GUARD_TYPE_VERSION_LOCKED_r11 1137 -#define _GUARD_TYPE_VERSION_LOCKED_r22 1138 -#define _GUARD_TYPE_VERSION_LOCKED_r33 1139 -#define _HANDLE_PENDING_AND_DEOPT_r00 1140 -#define _HANDLE_PENDING_AND_DEOPT_r10 1141 -#define _HANDLE_PENDING_AND_DEOPT_r20 1142 -#define _HANDLE_PENDING_AND_DEOPT_r30 1143 -#define _IMPORT_FROM_r12 1144 -#define _IMPORT_NAME_r21 1145 -#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS_r00 1146 -#define _INIT_CALL_PY_EXACT_ARGS_r01 1147 -#define _INIT_CALL_PY_EXACT_ARGS_0_r01 1148 -#define _INIT_CALL_PY_EXACT_ARGS_1_r01 1149 -#define _INIT_CALL_PY_EXACT_ARGS_2_r01 1150 -#define _INIT_CALL_PY_EXACT_ARGS_3_r01 1151 -#define _INIT_CALL_PY_EXACT_ARGS_4_r01 1152 -#define _INSERT_1_LOAD_CONST_INLINE_r02 1153 -#define _INSERT_1_LOAD_CONST_INLINE_r12 1154 -#define _INSERT_1_LOAD_CONST_INLINE_r23 1155 -#define _INSERT_1_LOAD_CONST_INLINE_BORROW_r02 1156 -#define _INSERT_1_LOAD_CONST_INLINE_BORROW_r12 1157 -#define _INSERT_1_LOAD_CONST_INLINE_BORROW_r23 1158 -#define _INSERT_2_LOAD_CONST_INLINE_BORROW_r03 1159 -#define _INSERT_2_LOAD_CONST_INLINE_BORROW_r13 1160 -#define _INSERT_2_LOAD_CONST_INLINE_BORROW_r23 1161 -#define _INSERT_NULL_r10 1162 -#define _INSTRUMENTED_FOR_ITER_r23 1163 -#define _INSTRUMENTED_INSTRUCTION_r00 1164 -#define _INSTRUMENTED_JUMP_FORWARD_r00 1165 -#define _INSTRUMENTED_JUMP_FORWARD_r11 1166 -#define _INSTRUMENTED_JUMP_FORWARD_r22 1167 -#define _INSTRUMENTED_JUMP_FORWARD_r33 1168 -#define _INSTRUMENTED_LINE_r00 1169 -#define _INSTRUMENTED_NOT_TAKEN_r00 1170 -#define _INSTRUMENTED_NOT_TAKEN_r11 1171 -#define _INSTRUMENTED_NOT_TAKEN_r22 1172 -#define _INSTRUMENTED_NOT_TAKEN_r33 1173 -#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r00 1174 -#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r10 1175 -#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r21 1176 -#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r32 1177 -#define _INSTRUMENTED_POP_JUMP_IF_NONE_r10 1178 -#define _INSTRUMENTED_POP_JUMP_IF_NOT_NONE_r10 1179 -#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r00 1180 -#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r10 1181 -#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r21 1182 -#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r32 1183 -#define _IS_NONE_r11 1184 -#define _IS_OP_r03 1185 -#define _IS_OP_r13 1186 -#define _IS_OP_r23 1187 -#define _ITER_CHECK_LIST_r02 1188 -#define _ITER_CHECK_LIST_r12 1189 -#define _ITER_CHECK_LIST_r22 1190 -#define _ITER_CHECK_LIST_r33 1191 -#define _ITER_CHECK_RANGE_r02 1192 -#define _ITER_CHECK_RANGE_r12 1193 -#define _ITER_CHECK_RANGE_r22 1194 -#define _ITER_CHECK_RANGE_r33 1195 -#define _ITER_CHECK_TUPLE_r02 1196 -#define _ITER_CHECK_TUPLE_r12 1197 -#define _ITER_CHECK_TUPLE_r22 1198 -#define _ITER_CHECK_TUPLE_r33 1199 -#define _ITER_JUMP_LIST_r02 1200 -#define _ITER_JUMP_LIST_r12 1201 -#define _ITER_JUMP_LIST_r22 1202 -#define _ITER_JUMP_LIST_r33 1203 -#define _ITER_JUMP_RANGE_r02 1204 -#define _ITER_JUMP_RANGE_r12 1205 -#define _ITER_JUMP_RANGE_r22 1206 -#define _ITER_JUMP_RANGE_r33 1207 -#define _ITER_JUMP_TUPLE_r02 1208 -#define _ITER_JUMP_TUPLE_r12 1209 -#define _ITER_JUMP_TUPLE_r22 1210 -#define _ITER_JUMP_TUPLE_r33 1211 -#define _ITER_NEXT_LIST_r23 1212 -#define _ITER_NEXT_LIST_TIER_TWO_r23 1213 -#define _ITER_NEXT_RANGE_r03 1214 -#define _ITER_NEXT_RANGE_r13 1215 -#define _ITER_NEXT_RANGE_r23 1216 -#define _ITER_NEXT_TUPLE_r03 1217 -#define _ITER_NEXT_TUPLE_r13 1218 -#define _ITER_NEXT_TUPLE_r23 1219 -#define _JUMP_BACKWARD_NO_INTERRUPT_r00 1220 -#define _JUMP_BACKWARD_NO_INTERRUPT_r11 1221 -#define _JUMP_BACKWARD_NO_INTERRUPT_r22 1222 -#define _JUMP_BACKWARD_NO_INTERRUPT_r33 1223 -#define _JUMP_TO_TOP_r00 1224 -#define _LIST_APPEND_r10 1225 -#define _LIST_EXTEND_r11 1226 -#define _LOAD_ATTR_r10 1227 -#define _LOAD_ATTR_CLASS_r11 1228 -#define _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_r11 1229 -#define _LOAD_ATTR_INSTANCE_VALUE_r02 1230 -#define _LOAD_ATTR_INSTANCE_VALUE_r12 1231 -#define _LOAD_ATTR_INSTANCE_VALUE_r23 1232 -#define _LOAD_ATTR_METHOD_LAZY_DICT_r02 1233 -#define _LOAD_ATTR_METHOD_LAZY_DICT_r12 1234 -#define _LOAD_ATTR_METHOD_LAZY_DICT_r23 1235 -#define _LOAD_ATTR_METHOD_NO_DICT_r02 1236 -#define _LOAD_ATTR_METHOD_NO_DICT_r12 1237 -#define _LOAD_ATTR_METHOD_NO_DICT_r23 1238 -#define _LOAD_ATTR_METHOD_WITH_VALUES_r02 1239 -#define _LOAD_ATTR_METHOD_WITH_VALUES_r12 1240 -#define _LOAD_ATTR_METHOD_WITH_VALUES_r23 1241 -#define _LOAD_ATTR_MODULE_r12 1242 -#define _LOAD_ATTR_NONDESCRIPTOR_NO_DICT_r11 1243 -#define _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES_r11 1244 -#define _LOAD_ATTR_PROPERTY_FRAME_r11 1245 -#define _LOAD_ATTR_SLOT_r02 1246 -#define _LOAD_ATTR_SLOT_r12 1247 -#define _LOAD_ATTR_SLOT_r23 1248 -#define _LOAD_ATTR_WITH_HINT_r12 1249 -#define _LOAD_BUILD_CLASS_r01 1250 -#define _LOAD_BYTECODE_r00 1251 -#define _LOAD_COMMON_CONSTANT_r01 1252 -#define _LOAD_COMMON_CONSTANT_r12 1253 -#define _LOAD_COMMON_CONSTANT_r23 1254 -#define _LOAD_CONST_r01 1255 -#define _LOAD_CONST_r12 1256 -#define _LOAD_CONST_r23 1257 -#define _LOAD_CONST_INLINE_r01 1258 -#define _LOAD_CONST_INLINE_r12 1259 -#define _LOAD_CONST_INLINE_r23 1260 -#define _LOAD_CONST_INLINE_BORROW_r01 1261 -#define _LOAD_CONST_INLINE_BORROW_r12 1262 -#define _LOAD_CONST_INLINE_BORROW_r23 1263 -#define _LOAD_CONST_UNDER_INLINE_r02 1264 -#define _LOAD_CONST_UNDER_INLINE_r12 1265 -#define _LOAD_CONST_UNDER_INLINE_r23 1266 -#define _LOAD_CONST_UNDER_INLINE_BORROW_r02 1267 -#define _LOAD_CONST_UNDER_INLINE_BORROW_r12 1268 -#define _LOAD_CONST_UNDER_INLINE_BORROW_r23 1269 -#define _LOAD_DEREF_r01 1270 -#define _LOAD_FAST_r01 1271 -#define _LOAD_FAST_r12 1272 -#define _LOAD_FAST_r23 1273 -#define _LOAD_FAST_0_r01 1274 -#define _LOAD_FAST_0_r12 1275 -#define _LOAD_FAST_0_r23 1276 -#define _LOAD_FAST_1_r01 1277 -#define _LOAD_FAST_1_r12 1278 -#define _LOAD_FAST_1_r23 1279 -#define _LOAD_FAST_2_r01 1280 -#define _LOAD_FAST_2_r12 1281 -#define _LOAD_FAST_2_r23 1282 -#define _LOAD_FAST_3_r01 1283 -#define _LOAD_FAST_3_r12 1284 -#define _LOAD_FAST_3_r23 1285 -#define _LOAD_FAST_4_r01 1286 -#define _LOAD_FAST_4_r12 1287 -#define _LOAD_FAST_4_r23 1288 -#define _LOAD_FAST_5_r01 1289 -#define _LOAD_FAST_5_r12 1290 -#define _LOAD_FAST_5_r23 1291 -#define _LOAD_FAST_6_r01 1292 -#define _LOAD_FAST_6_r12 1293 -#define _LOAD_FAST_6_r23 1294 -#define _LOAD_FAST_7_r01 1295 -#define _LOAD_FAST_7_r12 1296 -#define _LOAD_FAST_7_r23 1297 -#define _LOAD_FAST_AND_CLEAR_r01 1298 -#define _LOAD_FAST_AND_CLEAR_r12 1299 -#define _LOAD_FAST_AND_CLEAR_r23 1300 -#define _LOAD_FAST_BORROW_r01 1301 -#define _LOAD_FAST_BORROW_r12 1302 -#define _LOAD_FAST_BORROW_r23 1303 -#define _LOAD_FAST_BORROW_0_r01 1304 -#define _LOAD_FAST_BORROW_0_r12 1305 -#define _LOAD_FAST_BORROW_0_r23 1306 -#define _LOAD_FAST_BORROW_1_r01 1307 -#define _LOAD_FAST_BORROW_1_r12 1308 -#define _LOAD_FAST_BORROW_1_r23 1309 -#define _LOAD_FAST_BORROW_2_r01 1310 -#define _LOAD_FAST_BORROW_2_r12 1311 -#define _LOAD_FAST_BORROW_2_r23 1312 -#define _LOAD_FAST_BORROW_3_r01 1313 -#define _LOAD_FAST_BORROW_3_r12 1314 -#define _LOAD_FAST_BORROW_3_r23 1315 -#define _LOAD_FAST_BORROW_4_r01 1316 -#define _LOAD_FAST_BORROW_4_r12 1317 -#define _LOAD_FAST_BORROW_4_r23 1318 -#define _LOAD_FAST_BORROW_5_r01 1319 -#define _LOAD_FAST_BORROW_5_r12 1320 -#define _LOAD_FAST_BORROW_5_r23 1321 -#define _LOAD_FAST_BORROW_6_r01 1322 -#define _LOAD_FAST_BORROW_6_r12 1323 -#define _LOAD_FAST_BORROW_6_r23 1324 -#define _LOAD_FAST_BORROW_7_r01 1325 -#define _LOAD_FAST_BORROW_7_r12 1326 -#define _LOAD_FAST_BORROW_7_r23 1327 -#define _LOAD_FAST_BORROW_LOAD_FAST_BORROW_r02 1328 -#define _LOAD_FAST_BORROW_LOAD_FAST_BORROW_r13 1329 -#define _LOAD_FAST_CHECK_r01 1330 -#define _LOAD_FAST_CHECK_r12 1331 -#define _LOAD_FAST_CHECK_r23 1332 -#define _LOAD_FAST_LOAD_FAST_r02 1333 -#define _LOAD_FAST_LOAD_FAST_r13 1334 -#define _LOAD_FROM_DICT_OR_DEREF_r11 1335 -#define _LOAD_FROM_DICT_OR_GLOBALS_r11 1336 -#define _LOAD_GLOBAL_r00 1337 -#define _LOAD_GLOBAL_BUILTINS_r01 1338 -#define _LOAD_GLOBAL_MODULE_r01 1339 -#define _LOAD_LOCALS_r01 1340 -#define _LOAD_LOCALS_r12 1341 -#define _LOAD_LOCALS_r23 1342 -#define _LOAD_NAME_r01 1343 -#define _LOAD_SMALL_INT_r01 1344 -#define _LOAD_SMALL_INT_r12 1345 -#define _LOAD_SMALL_INT_r23 1346 -#define _LOAD_SMALL_INT_0_r01 1347 -#define _LOAD_SMALL_INT_0_r12 1348 -#define _LOAD_SMALL_INT_0_r23 1349 -#define _LOAD_SMALL_INT_1_r01 1350 -#define _LOAD_SMALL_INT_1_r12 1351 -#define _LOAD_SMALL_INT_1_r23 1352 -#define _LOAD_SMALL_INT_2_r01 1353 -#define _LOAD_SMALL_INT_2_r12 1354 -#define _LOAD_SMALL_INT_2_r23 1355 -#define _LOAD_SMALL_INT_3_r01 1356 -#define _LOAD_SMALL_INT_3_r12 1357 -#define _LOAD_SMALL_INT_3_r23 1358 -#define _LOAD_SPECIAL_r00 1359 -#define _LOAD_SUPER_ATTR_ATTR_r31 1360 -#define _LOAD_SUPER_ATTR_METHOD_r32 1361 -#define _LOCK_OBJECT_r01 1362 -#define _LOCK_OBJECT_r11 1363 -#define _LOCK_OBJECT_r22 1364 -#define _LOCK_OBJECT_r33 1365 -#define _MAKE_CALLARGS_A_TUPLE_r33 1366 -#define _MAKE_CELL_r00 1367 -#define _MAKE_FUNCTION_r11 1368 -#define _MAKE_HEAP_SAFE_r01 1369 -#define _MAKE_HEAP_SAFE_r11 1370 -#define _MAKE_HEAP_SAFE_r22 1371 -#define _MAKE_HEAP_SAFE_r33 1372 -#define _MAKE_WARM_r00 1373 -#define _MAKE_WARM_r11 1374 -#define _MAKE_WARM_r22 1375 -#define _MAKE_WARM_r33 1376 -#define _MAP_ADD_r20 1377 -#define _MATCH_CLASS_r33 1378 -#define _MATCH_KEYS_r23 1379 -#define _MATCH_MAPPING_r02 1380 -#define _MATCH_MAPPING_r12 1381 -#define _MATCH_MAPPING_r23 1382 -#define _MATCH_SEQUENCE_r02 1383 -#define _MATCH_SEQUENCE_r12 1384 -#define _MATCH_SEQUENCE_r23 1385 -#define _MAYBE_EXPAND_METHOD_r00 1386 -#define _MAYBE_EXPAND_METHOD_KW_r11 1387 -#define _MONITOR_CALL_r00 1388 -#define _MONITOR_CALL_KW_r11 1389 -#define _MONITOR_JUMP_BACKWARD_r00 1390 -#define _MONITOR_JUMP_BACKWARD_r11 1391 -#define _MONITOR_JUMP_BACKWARD_r22 1392 -#define _MONITOR_JUMP_BACKWARD_r33 1393 -#define _MONITOR_RESUME_r00 1394 -#define _NOP_r00 1395 -#define _NOP_r11 1396 -#define _NOP_r22 1397 -#define _NOP_r33 1398 -#define _POP_CALL_r20 1399 -#define _POP_CALL_LOAD_CONST_INLINE_BORROW_r21 1400 -#define _POP_CALL_ONE_r30 1401 -#define _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31 1402 -#define _POP_CALL_TWO_r30 1403 -#define _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31 1404 -#define _POP_EXCEPT_r10 1405 -#define _POP_ITER_r20 1406 -#define _POP_JUMP_IF_FALSE_r00 1407 -#define _POP_JUMP_IF_FALSE_r10 1408 -#define _POP_JUMP_IF_FALSE_r21 1409 -#define _POP_JUMP_IF_FALSE_r32 1410 -#define _POP_JUMP_IF_TRUE_r00 1411 -#define _POP_JUMP_IF_TRUE_r10 1412 -#define _POP_JUMP_IF_TRUE_r21 1413 -#define _POP_JUMP_IF_TRUE_r32 1414 -#define _POP_TOP_r10 1415 -#define _POP_TOP_FLOAT_r00 1416 -#define _POP_TOP_FLOAT_r10 1417 -#define _POP_TOP_FLOAT_r21 1418 -#define _POP_TOP_FLOAT_r32 1419 -#define _POP_TOP_INT_r00 1420 -#define _POP_TOP_INT_r10 1421 -#define _POP_TOP_INT_r21 1422 -#define _POP_TOP_INT_r32 1423 -#define _POP_TOP_LOAD_CONST_INLINE_r11 1424 -#define _POP_TOP_LOAD_CONST_INLINE_BORROW_r11 1425 -#define _POP_TOP_NOP_r00 1426 -#define _POP_TOP_NOP_r10 1427 -#define _POP_TOP_NOP_r21 1428 -#define _POP_TOP_NOP_r32 1429 -#define _POP_TOP_UNICODE_r00 1430 -#define _POP_TOP_UNICODE_r10 1431 -#define _POP_TOP_UNICODE_r21 1432 -#define _POP_TOP_UNICODE_r32 1433 -#define _POP_TWO_r20 1434 -#define _POP_TWO_LOAD_CONST_INLINE_BORROW_r21 1435 -#define _PUSH_EXC_INFO_r02 1436 -#define _PUSH_EXC_INFO_r12 1437 -#define _PUSH_EXC_INFO_r23 1438 -#define _PUSH_FRAME_r10 1439 -#define _PUSH_NULL_r01 1440 -#define _PUSH_NULL_r12 1441 -#define _PUSH_NULL_r23 1442 -#define _PUSH_NULL_CONDITIONAL_r00 1443 -#define _PY_FRAME_EX_r31 1444 -#define _PY_FRAME_GENERAL_r01 1445 -#define _PY_FRAME_KW_r11 1446 -#define _REPLACE_WITH_TRUE_r02 1447 -#define _REPLACE_WITH_TRUE_r12 1448 -#define _REPLACE_WITH_TRUE_r23 1449 -#define _RESUME_CHECK_r00 1450 -#define _RESUME_CHECK_r11 1451 -#define _RESUME_CHECK_r22 1452 -#define _RESUME_CHECK_r33 1453 -#define _RETURN_GENERATOR_r01 1454 -#define _RETURN_VALUE_r11 1455 -#define _SAVE_RETURN_OFFSET_r00 1456 -#define _SAVE_RETURN_OFFSET_r11 1457 -#define _SAVE_RETURN_OFFSET_r22 1458 -#define _SAVE_RETURN_OFFSET_r33 1459 -#define _SEND_r33 1460 -#define _SEND_GEN_FRAME_r33 1461 -#define _SETUP_ANNOTATIONS_r00 1462 -#define _SET_ADD_r10 1463 -#define _SET_FUNCTION_ATTRIBUTE_r01 1464 -#define _SET_FUNCTION_ATTRIBUTE_r11 1465 -#define _SET_FUNCTION_ATTRIBUTE_r21 1466 -#define _SET_FUNCTION_ATTRIBUTE_r32 1467 -#define _SET_IP_r00 1468 -#define _SET_IP_r11 1469 -#define _SET_IP_r22 1470 -#define _SET_IP_r33 1471 -#define _SET_UPDATE_r11 1472 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02 1473 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12 1474 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22 1475 -#define _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32 1476 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03 1477 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13 1478 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23 1479 -#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 1480 -#define _SPILL_OR_RELOAD_r01 1481 -#define _SPILL_OR_RELOAD_r02 1482 -#define _SPILL_OR_RELOAD_r03 1483 -#define _SPILL_OR_RELOAD_r10 1484 -#define _SPILL_OR_RELOAD_r12 1485 -#define _SPILL_OR_RELOAD_r13 1486 -#define _SPILL_OR_RELOAD_r20 1487 -#define _SPILL_OR_RELOAD_r21 1488 -#define _SPILL_OR_RELOAD_r23 1489 -#define _SPILL_OR_RELOAD_r30 1490 -#define _SPILL_OR_RELOAD_r31 1491 -#define _SPILL_OR_RELOAD_r32 1492 -#define _START_EXECUTOR_r00 1493 -#define _STORE_ATTR_r20 1494 -#define _STORE_ATTR_INSTANCE_VALUE_r21 1495 -#define _STORE_ATTR_SLOT_r21 1496 -#define _STORE_ATTR_WITH_HINT_r21 1497 -#define _STORE_DEREF_r10 1498 -#define _STORE_FAST_LOAD_FAST_r11 1499 -#define _STORE_FAST_STORE_FAST_r20 1500 -#define _STORE_GLOBAL_r10 1501 -#define _STORE_NAME_r10 1502 -#define _STORE_SLICE_r30 1503 -#define _STORE_SUBSCR_r30 1504 -#define _STORE_SUBSCR_DICT_r31 1505 -#define _STORE_SUBSCR_DICT_KNOWN_HASH_r31 1506 -#define _STORE_SUBSCR_LIST_INT_r32 1507 -#define _SWAP_r11 1508 -#define _SWAP_2_r02 1509 -#define _SWAP_2_r12 1510 -#define _SWAP_2_r22 1511 -#define _SWAP_2_r33 1512 -#define _SWAP_3_r03 1513 -#define _SWAP_3_r13 1514 -#define _SWAP_3_r23 1515 -#define _SWAP_3_r33 1516 -#define _SWAP_FAST_r01 1517 -#define _SWAP_FAST_r11 1518 -#define _SWAP_FAST_r22 1519 -#define _SWAP_FAST_r33 1520 -#define _SWAP_FAST_0_r01 1521 -#define _SWAP_FAST_0_r11 1522 -#define _SWAP_FAST_0_r22 1523 -#define _SWAP_FAST_0_r33 1524 -#define _SWAP_FAST_1_r01 1525 -#define _SWAP_FAST_1_r11 1526 -#define _SWAP_FAST_1_r22 1527 -#define _SWAP_FAST_1_r33 1528 -#define _SWAP_FAST_2_r01 1529 -#define _SWAP_FAST_2_r11 1530 -#define _SWAP_FAST_2_r22 1531 -#define _SWAP_FAST_2_r33 1532 -#define _SWAP_FAST_3_r01 1533 -#define _SWAP_FAST_3_r11 1534 -#define _SWAP_FAST_3_r22 1535 -#define _SWAP_FAST_3_r33 1536 -#define _SWAP_FAST_4_r01 1537 -#define _SWAP_FAST_4_r11 1538 -#define _SWAP_FAST_4_r22 1539 -#define _SWAP_FAST_4_r33 1540 -#define _SWAP_FAST_5_r01 1541 -#define _SWAP_FAST_5_r11 1542 -#define _SWAP_FAST_5_r22 1543 -#define _SWAP_FAST_5_r33 1544 -#define _SWAP_FAST_6_r01 1545 -#define _SWAP_FAST_6_r11 1546 -#define _SWAP_FAST_6_r22 1547 -#define _SWAP_FAST_6_r33 1548 -#define _SWAP_FAST_7_r01 1549 -#define _SWAP_FAST_7_r11 1550 -#define _SWAP_FAST_7_r22 1551 -#define _SWAP_FAST_7_r33 1552 -#define _TIER2_RESUME_CHECK_r00 1553 -#define _TIER2_RESUME_CHECK_r11 1554 -#define _TIER2_RESUME_CHECK_r22 1555 -#define _TIER2_RESUME_CHECK_r33 1556 -#define _TO_BOOL_r11 1557 -#define _TO_BOOL_BOOL_r01 1558 -#define _TO_BOOL_BOOL_r11 1559 -#define _TO_BOOL_BOOL_r22 1560 -#define _TO_BOOL_BOOL_r33 1561 -#define _TO_BOOL_INT_r02 1562 -#define _TO_BOOL_INT_r12 1563 -#define _TO_BOOL_INT_r23 1564 -#define _TO_BOOL_LIST_r02 1565 -#define _TO_BOOL_LIST_r12 1566 -#define _TO_BOOL_LIST_r23 1567 -#define _TO_BOOL_NONE_r01 1568 -#define _TO_BOOL_NONE_r11 1569 -#define _TO_BOOL_NONE_r22 1570 -#define _TO_BOOL_NONE_r33 1571 -#define _TO_BOOL_STR_r02 1572 -#define _TO_BOOL_STR_r12 1573 -#define _TO_BOOL_STR_r23 1574 -#define _TRACE_RECORD_r00 1575 -#define _UNARY_INVERT_r12 1576 -#define _UNARY_NEGATIVE_r12 1577 -#define _UNARY_NEGATIVE_FLOAT_INPLACE_r02 1578 -#define _UNARY_NEGATIVE_FLOAT_INPLACE_r12 1579 -#define _UNARY_NEGATIVE_FLOAT_INPLACE_r23 1580 -#define _UNARY_NOT_r01 1581 -#define _UNARY_NOT_r11 1582 -#define _UNARY_NOT_r22 1583 -#define _UNARY_NOT_r33 1584 -#define _UNPACK_EX_r10 1585 -#define _UNPACK_SEQUENCE_r10 1586 -#define _UNPACK_SEQUENCE_LIST_r10 1587 -#define _UNPACK_SEQUENCE_TUPLE_r10 1588 -#define _UNPACK_SEQUENCE_TWO_TUPLE_r12 1589 -#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE_r03 1590 -#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE_r13 1591 -#define _UNPACK_SEQUENCE_UNIQUE_TUPLE_r10 1592 -#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r02 1593 -#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r12 1594 -#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r23 1595 -#define _WITH_EXCEPT_START_r33 1596 -#define _YIELD_VALUE_r11 1597 -#define MAX_UOP_REGS_ID 1597 +#define _YIELD_VALUE 629 +#define MAX_UOP_ID 629 +#define _ALLOCATE_OBJECT_r00 630 +#define _BINARY_OP_r23 631 +#define _BINARY_OP_ADD_FLOAT_r03 632 +#define _BINARY_OP_ADD_FLOAT_r13 633 +#define _BINARY_OP_ADD_FLOAT_r23 634 +#define _BINARY_OP_ADD_FLOAT_INPLACE_r03 635 +#define _BINARY_OP_ADD_FLOAT_INPLACE_r13 636 +#define _BINARY_OP_ADD_FLOAT_INPLACE_r23 637 +#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r03 638 +#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r13 639 +#define _BINARY_OP_ADD_FLOAT_INPLACE_RIGHT_r23 640 +#define _BINARY_OP_ADD_INT_r03 641 +#define _BINARY_OP_ADD_INT_r13 642 +#define _BINARY_OP_ADD_INT_r23 643 +#define _BINARY_OP_ADD_INT_INPLACE_r03 644 +#define _BINARY_OP_ADD_INT_INPLACE_r13 645 +#define _BINARY_OP_ADD_INT_INPLACE_r23 646 +#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r03 647 +#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r13 648 +#define _BINARY_OP_ADD_INT_INPLACE_RIGHT_r23 649 +#define _BINARY_OP_ADD_UNICODE_r03 650 +#define _BINARY_OP_ADD_UNICODE_r13 651 +#define _BINARY_OP_ADD_UNICODE_r23 652 +#define _BINARY_OP_EXTEND_r23 653 +#define _BINARY_OP_INPLACE_ADD_UNICODE_r21 654 +#define _BINARY_OP_MULTIPLY_FLOAT_r03 655 +#define _BINARY_OP_MULTIPLY_FLOAT_r13 656 +#define _BINARY_OP_MULTIPLY_FLOAT_r23 657 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r03 658 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r13 659 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_r23 660 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r03 661 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r13 662 +#define _BINARY_OP_MULTIPLY_FLOAT_INPLACE_RIGHT_r23 663 +#define _BINARY_OP_MULTIPLY_INT_r03 664 +#define _BINARY_OP_MULTIPLY_INT_r13 665 +#define _BINARY_OP_MULTIPLY_INT_r23 666 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_r03 667 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_r13 668 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_r23 669 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r03 670 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r13 671 +#define _BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT_r23 672 +#define _BINARY_OP_SUBSCR_CHECK_FUNC_r23 673 +#define _BINARY_OP_SUBSCR_DICT_r23 674 +#define _BINARY_OP_SUBSCR_DICT_KNOWN_HASH_r23 675 +#define _BINARY_OP_SUBSCR_INIT_CALL_r01 676 +#define _BINARY_OP_SUBSCR_INIT_CALL_r11 677 +#define _BINARY_OP_SUBSCR_INIT_CALL_r21 678 +#define _BINARY_OP_SUBSCR_INIT_CALL_r31 679 +#define _BINARY_OP_SUBSCR_LIST_INT_r23 680 +#define _BINARY_OP_SUBSCR_LIST_SLICE_r23 681 +#define _BINARY_OP_SUBSCR_STR_INT_r23 682 +#define _BINARY_OP_SUBSCR_TUPLE_INT_r03 683 +#define _BINARY_OP_SUBSCR_TUPLE_INT_r13 684 +#define _BINARY_OP_SUBSCR_TUPLE_INT_r23 685 +#define _BINARY_OP_SUBSCR_USTR_INT_r23 686 +#define _BINARY_OP_SUBTRACT_FLOAT_r03 687 +#define _BINARY_OP_SUBTRACT_FLOAT_r13 688 +#define _BINARY_OP_SUBTRACT_FLOAT_r23 689 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r03 690 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r13 691 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_r23 692 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r03 693 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r13 694 +#define _BINARY_OP_SUBTRACT_FLOAT_INPLACE_RIGHT_r23 695 +#define _BINARY_OP_SUBTRACT_INT_r03 696 +#define _BINARY_OP_SUBTRACT_INT_r13 697 +#define _BINARY_OP_SUBTRACT_INT_r23 698 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_r03 699 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_r13 700 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_r23 701 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r03 702 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r13 703 +#define _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT_r23 704 +#define _BINARY_SLICE_r31 705 +#define _BUILD_INTERPOLATION_r01 706 +#define _BUILD_LIST_r01 707 +#define _BUILD_MAP_r01 708 +#define _BUILD_SET_r01 709 +#define _BUILD_SLICE_r01 710 +#define _BUILD_STRING_r01 711 +#define _BUILD_TEMPLATE_r21 712 +#define _BUILD_TUPLE_r01 713 +#define _CALL_BUILTIN_CLASS_r00 714 +#define _CALL_BUILTIN_FAST_r00 715 +#define _CALL_BUILTIN_FAST_WITH_KEYWORDS_r00 716 +#define _CALL_BUILTIN_O_r03 717 +#define _CALL_FUNCTION_EX_NON_PY_GENERAL_r31 718 +#define _CALL_INTRINSIC_1_r12 719 +#define _CALL_INTRINSIC_2_r23 720 +#define _CALL_ISINSTANCE_r31 721 +#define _CALL_KW_NON_PY_r11 722 +#define _CALL_LEN_r33 723 +#define _CALL_LIST_APPEND_r03 724 +#define _CALL_LIST_APPEND_r13 725 +#define _CALL_LIST_APPEND_r23 726 +#define _CALL_LIST_APPEND_r33 727 +#define _CALL_METHOD_DESCRIPTOR_FAST_r00 728 +#define _CALL_METHOD_DESCRIPTOR_FAST_INLINE_r00 729 +#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00 730 +#define _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r00 731 +#define _CALL_METHOD_DESCRIPTOR_NOARGS_r03 732 +#define _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r03 733 +#define _CALL_METHOD_DESCRIPTOR_O_r03 734 +#define _CALL_METHOD_DESCRIPTOR_O_INLINE_r03 735 +#define _CALL_NON_PY_GENERAL_r01 736 +#define _CALL_STR_1_r32 737 +#define _CALL_TUPLE_1_r32 738 +#define _CALL_TYPE_1_r02 739 +#define _CALL_TYPE_1_r12 740 +#define _CALL_TYPE_1_r22 741 +#define _CALL_TYPE_1_r32 742 +#define _CHECK_ATTR_CLASS_r01 743 +#define _CHECK_ATTR_CLASS_r11 744 +#define _CHECK_ATTR_CLASS_r22 745 +#define _CHECK_ATTR_CLASS_r33 746 +#define _CHECK_ATTR_METHOD_LAZY_DICT_r01 747 +#define _CHECK_ATTR_METHOD_LAZY_DICT_r11 748 +#define _CHECK_ATTR_METHOD_LAZY_DICT_r22 749 +#define _CHECK_ATTR_METHOD_LAZY_DICT_r33 750 +#define _CHECK_CALL_BOUND_METHOD_EXACT_ARGS_r00 751 +#define _CHECK_EG_MATCH_r22 752 +#define _CHECK_EXC_MATCH_r22 753 +#define _CHECK_FUNCTION_EXACT_ARGS_r00 754 +#define _CHECK_FUNCTION_VERSION_r00 755 +#define _CHECK_FUNCTION_VERSION_INLINE_r00 756 +#define _CHECK_FUNCTION_VERSION_INLINE_r11 757 +#define _CHECK_FUNCTION_VERSION_INLINE_r22 758 +#define _CHECK_FUNCTION_VERSION_INLINE_r33 759 +#define _CHECK_FUNCTION_VERSION_KW_r11 760 +#define _CHECK_IS_NOT_PY_CALLABLE_r00 761 +#define _CHECK_IS_NOT_PY_CALLABLE_EX_r03 762 +#define _CHECK_IS_NOT_PY_CALLABLE_EX_r13 763 +#define _CHECK_IS_NOT_PY_CALLABLE_EX_r23 764 +#define _CHECK_IS_NOT_PY_CALLABLE_EX_r33 765 +#define _CHECK_IS_NOT_PY_CALLABLE_KW_r11 766 +#define _CHECK_IS_PY_CALLABLE_EX_r03 767 +#define _CHECK_IS_PY_CALLABLE_EX_r13 768 +#define _CHECK_IS_PY_CALLABLE_EX_r23 769 +#define _CHECK_IS_PY_CALLABLE_EX_r33 770 +#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r01 771 +#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r11 772 +#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r22 773 +#define _CHECK_MANAGED_OBJECT_HAS_VALUES_r33 774 +#define _CHECK_METHOD_VERSION_r00 775 +#define _CHECK_METHOD_VERSION_KW_r11 776 +#define _CHECK_OBJECT_r00 777 +#define _CHECK_PEP_523_r00 778 +#define _CHECK_PEP_523_r11 779 +#define _CHECK_PEP_523_r22 780 +#define _CHECK_PEP_523_r33 781 +#define _CHECK_PERIODIC_r00 782 +#define _CHECK_PERIODIC_AT_END_r00 783 +#define _CHECK_PERIODIC_IF_NOT_YIELD_FROM_r00 784 +#define _CHECK_RECURSION_LIMIT_r00 785 +#define _CHECK_RECURSION_LIMIT_r11 786 +#define _CHECK_RECURSION_LIMIT_r22 787 +#define _CHECK_RECURSION_LIMIT_r33 788 +#define _CHECK_RECURSION_REMAINING_r00 789 +#define _CHECK_RECURSION_REMAINING_r11 790 +#define _CHECK_RECURSION_REMAINING_r22 791 +#define _CHECK_RECURSION_REMAINING_r33 792 +#define _CHECK_STACK_SPACE_r00 793 +#define _CHECK_STACK_SPACE_OPERAND_r00 794 +#define _CHECK_STACK_SPACE_OPERAND_r11 795 +#define _CHECK_STACK_SPACE_OPERAND_r22 796 +#define _CHECK_STACK_SPACE_OPERAND_r33 797 +#define _CHECK_VALIDITY_r00 798 +#define _CHECK_VALIDITY_r11 799 +#define _CHECK_VALIDITY_r22 800 +#define _CHECK_VALIDITY_r33 801 +#define _COLD_DYNAMIC_EXIT_r00 802 +#define _COLD_EXIT_r00 803 +#define _COMPARE_OP_r21 804 +#define _COMPARE_OP_FLOAT_r03 805 +#define _COMPARE_OP_FLOAT_r13 806 +#define _COMPARE_OP_FLOAT_r23 807 +#define _COMPARE_OP_INT_r23 808 +#define _COMPARE_OP_STR_r23 809 +#define _CONTAINS_OP_r23 810 +#define _CONTAINS_OP_DICT_r23 811 +#define _CONTAINS_OP_SET_r23 812 +#define _CONVERT_VALUE_r11 813 +#define _COPY_r01 814 +#define _COPY_1_r02 815 +#define _COPY_1_r12 816 +#define _COPY_1_r23 817 +#define _COPY_2_r03 818 +#define _COPY_2_r13 819 +#define _COPY_2_r23 820 +#define _COPY_3_r03 821 +#define _COPY_3_r13 822 +#define _COPY_3_r23 823 +#define _COPY_3_r33 824 +#define _COPY_FREE_VARS_r00 825 +#define _COPY_FREE_VARS_r11 826 +#define _COPY_FREE_VARS_r22 827 +#define _COPY_FREE_VARS_r33 828 +#define _CREATE_INIT_FRAME_r01 829 +#define _DELETE_ATTR_r10 830 +#define _DELETE_DEREF_r00 831 +#define _DELETE_FAST_r00 832 +#define _DELETE_GLOBAL_r00 833 +#define _DELETE_NAME_r00 834 +#define _DELETE_SUBSCR_r20 835 +#define _DEOPT_r00 836 +#define _DEOPT_r10 837 +#define _DEOPT_r20 838 +#define _DEOPT_r30 839 +#define _DICT_MERGE_r11 840 +#define _DICT_UPDATE_r11 841 +#define _DO_CALL_r01 842 +#define _DO_CALL_FUNCTION_EX_r31 843 +#define _DO_CALL_KW_r11 844 +#define _DYNAMIC_EXIT_r00 845 +#define _DYNAMIC_EXIT_r10 846 +#define _DYNAMIC_EXIT_r20 847 +#define _DYNAMIC_EXIT_r30 848 +#define _END_FOR_r10 849 +#define _END_SEND_r31 850 +#define _ERROR_POP_N_r00 851 +#define _EXIT_INIT_CHECK_r10 852 +#define _EXIT_TRACE_r00 853 +#define _EXIT_TRACE_r10 854 +#define _EXIT_TRACE_r20 855 +#define _EXIT_TRACE_r30 856 +#define _EXPAND_METHOD_r00 857 +#define _EXPAND_METHOD_KW_r11 858 +#define _FATAL_ERROR_r00 859 +#define _FATAL_ERROR_r11 860 +#define _FATAL_ERROR_r22 861 +#define _FATAL_ERROR_r33 862 +#define _FORMAT_SIMPLE_r11 863 +#define _FORMAT_WITH_SPEC_r21 864 +#define _FOR_ITER_r23 865 +#define _FOR_ITER_GEN_FRAME_r03 866 +#define _FOR_ITER_GEN_FRAME_r13 867 +#define _FOR_ITER_GEN_FRAME_r23 868 +#define _FOR_ITER_TIER_TWO_r23 869 +#define _GET_AITER_r11 870 +#define _GET_ANEXT_r12 871 +#define _GET_AWAITABLE_r11 872 +#define _GET_ITER_r12 873 +#define _GET_LEN_r12 874 +#define _GUARD_BINARY_OP_EXTEND_r22 875 +#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r02 876 +#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r12 877 +#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r22 878 +#define _GUARD_BINARY_OP_SUBSCR_TUPLE_INT_BOUNDS_r33 879 +#define _GUARD_BIT_IS_SET_POP_r00 880 +#define _GUARD_BIT_IS_SET_POP_r10 881 +#define _GUARD_BIT_IS_SET_POP_r21 882 +#define _GUARD_BIT_IS_SET_POP_r32 883 +#define _GUARD_BIT_IS_SET_POP_4_r00 884 +#define _GUARD_BIT_IS_SET_POP_4_r10 885 +#define _GUARD_BIT_IS_SET_POP_4_r21 886 +#define _GUARD_BIT_IS_SET_POP_4_r32 887 +#define _GUARD_BIT_IS_SET_POP_5_r00 888 +#define _GUARD_BIT_IS_SET_POP_5_r10 889 +#define _GUARD_BIT_IS_SET_POP_5_r21 890 +#define _GUARD_BIT_IS_SET_POP_5_r32 891 +#define _GUARD_BIT_IS_SET_POP_6_r00 892 +#define _GUARD_BIT_IS_SET_POP_6_r10 893 +#define _GUARD_BIT_IS_SET_POP_6_r21 894 +#define _GUARD_BIT_IS_SET_POP_6_r32 895 +#define _GUARD_BIT_IS_SET_POP_7_r00 896 +#define _GUARD_BIT_IS_SET_POP_7_r10 897 +#define _GUARD_BIT_IS_SET_POP_7_r21 898 +#define _GUARD_BIT_IS_SET_POP_7_r32 899 +#define _GUARD_BIT_IS_UNSET_POP_r00 900 +#define _GUARD_BIT_IS_UNSET_POP_r10 901 +#define _GUARD_BIT_IS_UNSET_POP_r21 902 +#define _GUARD_BIT_IS_UNSET_POP_r32 903 +#define _GUARD_BIT_IS_UNSET_POP_4_r00 904 +#define _GUARD_BIT_IS_UNSET_POP_4_r10 905 +#define _GUARD_BIT_IS_UNSET_POP_4_r21 906 +#define _GUARD_BIT_IS_UNSET_POP_4_r32 907 +#define _GUARD_BIT_IS_UNSET_POP_5_r00 908 +#define _GUARD_BIT_IS_UNSET_POP_5_r10 909 +#define _GUARD_BIT_IS_UNSET_POP_5_r21 910 +#define _GUARD_BIT_IS_UNSET_POP_5_r32 911 +#define _GUARD_BIT_IS_UNSET_POP_6_r00 912 +#define _GUARD_BIT_IS_UNSET_POP_6_r10 913 +#define _GUARD_BIT_IS_UNSET_POP_6_r21 914 +#define _GUARD_BIT_IS_UNSET_POP_6_r32 915 +#define _GUARD_BIT_IS_UNSET_POP_7_r00 916 +#define _GUARD_BIT_IS_UNSET_POP_7_r10 917 +#define _GUARD_BIT_IS_UNSET_POP_7_r21 918 +#define _GUARD_BIT_IS_UNSET_POP_7_r32 919 +#define _GUARD_CALLABLE_BUILTIN_CLASS_r00 920 +#define _GUARD_CALLABLE_BUILTIN_FAST_r00 921 +#define _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS_r00 922 +#define _GUARD_CALLABLE_BUILTIN_O_r00 923 +#define _GUARD_CALLABLE_ISINSTANCE_r03 924 +#define _GUARD_CALLABLE_ISINSTANCE_r13 925 +#define _GUARD_CALLABLE_ISINSTANCE_r23 926 +#define _GUARD_CALLABLE_ISINSTANCE_r33 927 +#define _GUARD_CALLABLE_LEN_r03 928 +#define _GUARD_CALLABLE_LEN_r13 929 +#define _GUARD_CALLABLE_LEN_r23 930 +#define _GUARD_CALLABLE_LEN_r33 931 +#define _GUARD_CALLABLE_LIST_APPEND_r03 932 +#define _GUARD_CALLABLE_LIST_APPEND_r13 933 +#define _GUARD_CALLABLE_LIST_APPEND_r23 934 +#define _GUARD_CALLABLE_LIST_APPEND_r33 935 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_r00 936 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00 937 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS_r00 938 +#define _GUARD_CALLABLE_METHOD_DESCRIPTOR_O_r00 939 +#define _GUARD_CALLABLE_STR_1_r03 940 +#define _GUARD_CALLABLE_STR_1_r13 941 +#define _GUARD_CALLABLE_STR_1_r23 942 +#define _GUARD_CALLABLE_STR_1_r33 943 +#define _GUARD_CALLABLE_TUPLE_1_r03 944 +#define _GUARD_CALLABLE_TUPLE_1_r13 945 +#define _GUARD_CALLABLE_TUPLE_1_r23 946 +#define _GUARD_CALLABLE_TUPLE_1_r33 947 +#define _GUARD_CALLABLE_TYPE_1_r03 948 +#define _GUARD_CALLABLE_TYPE_1_r13 949 +#define _GUARD_CALLABLE_TYPE_1_r23 950 +#define _GUARD_CALLABLE_TYPE_1_r33 951 +#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r00 952 +#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r11 953 +#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r22 954 +#define _GUARD_CODE_VERSION_RETURN_GENERATOR_r33 955 +#define _GUARD_CODE_VERSION_RETURN_VALUE_r00 956 +#define _GUARD_CODE_VERSION_RETURN_VALUE_r11 957 +#define _GUARD_CODE_VERSION_RETURN_VALUE_r22 958 +#define _GUARD_CODE_VERSION_RETURN_VALUE_r33 959 +#define _GUARD_CODE_VERSION_YIELD_VALUE_r00 960 +#define _GUARD_CODE_VERSION_YIELD_VALUE_r11 961 +#define _GUARD_CODE_VERSION_YIELD_VALUE_r22 962 +#define _GUARD_CODE_VERSION_YIELD_VALUE_r33 963 +#define _GUARD_CODE_VERSION__PUSH_FRAME_r00 964 +#define _GUARD_CODE_VERSION__PUSH_FRAME_r11 965 +#define _GUARD_CODE_VERSION__PUSH_FRAME_r22 966 +#define _GUARD_CODE_VERSION__PUSH_FRAME_r33 967 +#define _GUARD_DORV_NO_DICT_r01 968 +#define _GUARD_DORV_NO_DICT_r11 969 +#define _GUARD_DORV_NO_DICT_r22 970 +#define _GUARD_DORV_NO_DICT_r33 971 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r01 972 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r11 973 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r22 974 +#define _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT_r33 975 +#define _GUARD_GLOBALS_VERSION_r00 976 +#define _GUARD_GLOBALS_VERSION_r11 977 +#define _GUARD_GLOBALS_VERSION_r22 978 +#define _GUARD_GLOBALS_VERSION_r33 979 +#define _GUARD_IP_RETURN_GENERATOR_r00 980 +#define _GUARD_IP_RETURN_GENERATOR_r11 981 +#define _GUARD_IP_RETURN_GENERATOR_r22 982 +#define _GUARD_IP_RETURN_GENERATOR_r33 983 +#define _GUARD_IP_RETURN_VALUE_r00 984 +#define _GUARD_IP_RETURN_VALUE_r11 985 +#define _GUARD_IP_RETURN_VALUE_r22 986 +#define _GUARD_IP_RETURN_VALUE_r33 987 +#define _GUARD_IP_YIELD_VALUE_r00 988 +#define _GUARD_IP_YIELD_VALUE_r11 989 +#define _GUARD_IP_YIELD_VALUE_r22 990 +#define _GUARD_IP_YIELD_VALUE_r33 991 +#define _GUARD_IP__PUSH_FRAME_r00 992 +#define _GUARD_IP__PUSH_FRAME_r11 993 +#define _GUARD_IP__PUSH_FRAME_r22 994 +#define _GUARD_IP__PUSH_FRAME_r33 995 +#define _GUARD_IS_FALSE_POP_r00 996 +#define _GUARD_IS_FALSE_POP_r10 997 +#define _GUARD_IS_FALSE_POP_r21 998 +#define _GUARD_IS_FALSE_POP_r32 999 +#define _GUARD_IS_NONE_POP_r00 1000 +#define _GUARD_IS_NONE_POP_r10 1001 +#define _GUARD_IS_NONE_POP_r21 1002 +#define _GUARD_IS_NONE_POP_r32 1003 +#define _GUARD_IS_NOT_NONE_POP_r10 1004 +#define _GUARD_IS_TRUE_POP_r00 1005 +#define _GUARD_IS_TRUE_POP_r10 1006 +#define _GUARD_IS_TRUE_POP_r21 1007 +#define _GUARD_IS_TRUE_POP_r32 1008 +#define _GUARD_KEYS_VERSION_r01 1009 +#define _GUARD_KEYS_VERSION_r11 1010 +#define _GUARD_KEYS_VERSION_r22 1011 +#define _GUARD_KEYS_VERSION_r33 1012 +#define _GUARD_LOAD_SUPER_ATTR_METHOD_r03 1013 +#define _GUARD_LOAD_SUPER_ATTR_METHOD_r13 1014 +#define _GUARD_LOAD_SUPER_ATTR_METHOD_r23 1015 +#define _GUARD_LOAD_SUPER_ATTR_METHOD_r33 1016 +#define _GUARD_NOS_ANY_DICT_r02 1017 +#define _GUARD_NOS_ANY_DICT_r12 1018 +#define _GUARD_NOS_ANY_DICT_r22 1019 +#define _GUARD_NOS_ANY_DICT_r33 1020 +#define _GUARD_NOS_COMPACT_ASCII_r02 1021 +#define _GUARD_NOS_COMPACT_ASCII_r12 1022 +#define _GUARD_NOS_COMPACT_ASCII_r22 1023 +#define _GUARD_NOS_COMPACT_ASCII_r33 1024 +#define _GUARD_NOS_DICT_r02 1025 +#define _GUARD_NOS_DICT_r12 1026 +#define _GUARD_NOS_DICT_r22 1027 +#define _GUARD_NOS_DICT_r33 1028 +#define _GUARD_NOS_FLOAT_r02 1029 +#define _GUARD_NOS_FLOAT_r12 1030 +#define _GUARD_NOS_FLOAT_r22 1031 +#define _GUARD_NOS_FLOAT_r33 1032 +#define _GUARD_NOS_INT_r02 1033 +#define _GUARD_NOS_INT_r12 1034 +#define _GUARD_NOS_INT_r22 1035 +#define _GUARD_NOS_INT_r33 1036 +#define _GUARD_NOS_LIST_r02 1037 +#define _GUARD_NOS_LIST_r12 1038 +#define _GUARD_NOS_LIST_r22 1039 +#define _GUARD_NOS_LIST_r33 1040 +#define _GUARD_NOS_NOT_NULL_r02 1041 +#define _GUARD_NOS_NOT_NULL_r12 1042 +#define _GUARD_NOS_NOT_NULL_r22 1043 +#define _GUARD_NOS_NOT_NULL_r33 1044 +#define _GUARD_NOS_NULL_r02 1045 +#define _GUARD_NOS_NULL_r12 1046 +#define _GUARD_NOS_NULL_r22 1047 +#define _GUARD_NOS_NULL_r33 1048 +#define _GUARD_NOS_OVERFLOWED_r02 1049 +#define _GUARD_NOS_OVERFLOWED_r12 1050 +#define _GUARD_NOS_OVERFLOWED_r22 1051 +#define _GUARD_NOS_OVERFLOWED_r33 1052 +#define _GUARD_NOS_TUPLE_r02 1053 +#define _GUARD_NOS_TUPLE_r12 1054 +#define _GUARD_NOS_TUPLE_r22 1055 +#define _GUARD_NOS_TUPLE_r33 1056 +#define _GUARD_NOS_TYPE_VERSION_r02 1057 +#define _GUARD_NOS_TYPE_VERSION_r12 1058 +#define _GUARD_NOS_TYPE_VERSION_r22 1059 +#define _GUARD_NOS_TYPE_VERSION_r33 1060 +#define _GUARD_NOS_UNICODE_r02 1061 +#define _GUARD_NOS_UNICODE_r12 1062 +#define _GUARD_NOS_UNICODE_r22 1063 +#define _GUARD_NOS_UNICODE_r33 1064 +#define _GUARD_NOT_EXHAUSTED_LIST_r02 1065 +#define _GUARD_NOT_EXHAUSTED_LIST_r12 1066 +#define _GUARD_NOT_EXHAUSTED_LIST_r22 1067 +#define _GUARD_NOT_EXHAUSTED_LIST_r33 1068 +#define _GUARD_NOT_EXHAUSTED_RANGE_r02 1069 +#define _GUARD_NOT_EXHAUSTED_RANGE_r12 1070 +#define _GUARD_NOT_EXHAUSTED_RANGE_r22 1071 +#define _GUARD_NOT_EXHAUSTED_RANGE_r33 1072 +#define _GUARD_NOT_EXHAUSTED_TUPLE_r02 1073 +#define _GUARD_NOT_EXHAUSTED_TUPLE_r12 1074 +#define _GUARD_NOT_EXHAUSTED_TUPLE_r22 1075 +#define _GUARD_NOT_EXHAUSTED_TUPLE_r33 1076 +#define _GUARD_THIRD_NULL_r03 1077 +#define _GUARD_THIRD_NULL_r13 1078 +#define _GUARD_THIRD_NULL_r23 1079 +#define _GUARD_THIRD_NULL_r33 1080 +#define _GUARD_TOS_ANY_DICT_r01 1081 +#define _GUARD_TOS_ANY_DICT_r11 1082 +#define _GUARD_TOS_ANY_DICT_r22 1083 +#define _GUARD_TOS_ANY_DICT_r33 1084 +#define _GUARD_TOS_ANY_SET_r01 1085 +#define _GUARD_TOS_ANY_SET_r11 1086 +#define _GUARD_TOS_ANY_SET_r22 1087 +#define _GUARD_TOS_ANY_SET_r33 1088 +#define _GUARD_TOS_DICT_r01 1089 +#define _GUARD_TOS_DICT_r11 1090 +#define _GUARD_TOS_DICT_r22 1091 +#define _GUARD_TOS_DICT_r33 1092 +#define _GUARD_TOS_FLOAT_r01 1093 +#define _GUARD_TOS_FLOAT_r11 1094 +#define _GUARD_TOS_FLOAT_r22 1095 +#define _GUARD_TOS_FLOAT_r33 1096 +#define _GUARD_TOS_FROZENDICT_r01 1097 +#define _GUARD_TOS_FROZENDICT_r11 1098 +#define _GUARD_TOS_FROZENDICT_r22 1099 +#define _GUARD_TOS_FROZENDICT_r33 1100 +#define _GUARD_TOS_FROZENSET_r01 1101 +#define _GUARD_TOS_FROZENSET_r11 1102 +#define _GUARD_TOS_FROZENSET_r22 1103 +#define _GUARD_TOS_FROZENSET_r33 1104 +#define _GUARD_TOS_INT_r01 1105 +#define _GUARD_TOS_INT_r11 1106 +#define _GUARD_TOS_INT_r22 1107 +#define _GUARD_TOS_INT_r33 1108 +#define _GUARD_TOS_LIST_r01 1109 +#define _GUARD_TOS_LIST_r11 1110 +#define _GUARD_TOS_LIST_r22 1111 +#define _GUARD_TOS_LIST_r33 1112 +#define _GUARD_TOS_OVERFLOWED_r01 1113 +#define _GUARD_TOS_OVERFLOWED_r11 1114 +#define _GUARD_TOS_OVERFLOWED_r22 1115 +#define _GUARD_TOS_OVERFLOWED_r33 1116 +#define _GUARD_TOS_SET_r01 1117 +#define _GUARD_TOS_SET_r11 1118 +#define _GUARD_TOS_SET_r22 1119 +#define _GUARD_TOS_SET_r33 1120 +#define _GUARD_TOS_SLICE_r01 1121 +#define _GUARD_TOS_SLICE_r11 1122 +#define _GUARD_TOS_SLICE_r22 1123 +#define _GUARD_TOS_SLICE_r33 1124 +#define _GUARD_TOS_TUPLE_r01 1125 +#define _GUARD_TOS_TUPLE_r11 1126 +#define _GUARD_TOS_TUPLE_r22 1127 +#define _GUARD_TOS_TUPLE_r33 1128 +#define _GUARD_TOS_UNICODE_r01 1129 +#define _GUARD_TOS_UNICODE_r11 1130 +#define _GUARD_TOS_UNICODE_r22 1131 +#define _GUARD_TOS_UNICODE_r33 1132 +#define _GUARD_TYPE_VERSION_r01 1133 +#define _GUARD_TYPE_VERSION_r11 1134 +#define _GUARD_TYPE_VERSION_r22 1135 +#define _GUARD_TYPE_VERSION_r33 1136 +#define _GUARD_TYPE_VERSION_LOCKED_r01 1137 +#define _GUARD_TYPE_VERSION_LOCKED_r11 1138 +#define _GUARD_TYPE_VERSION_LOCKED_r22 1139 +#define _GUARD_TYPE_VERSION_LOCKED_r33 1140 +#define _HANDLE_PENDING_AND_DEOPT_r00 1141 +#define _HANDLE_PENDING_AND_DEOPT_r10 1142 +#define _HANDLE_PENDING_AND_DEOPT_r20 1143 +#define _HANDLE_PENDING_AND_DEOPT_r30 1144 +#define _IMPORT_FROM_r12 1145 +#define _IMPORT_NAME_r21 1146 +#define _INIT_CALL_BOUND_METHOD_EXACT_ARGS_r00 1147 +#define _INIT_CALL_PY_EXACT_ARGS_r01 1148 +#define _INIT_CALL_PY_EXACT_ARGS_0_r01 1149 +#define _INIT_CALL_PY_EXACT_ARGS_1_r01 1150 +#define _INIT_CALL_PY_EXACT_ARGS_2_r01 1151 +#define _INIT_CALL_PY_EXACT_ARGS_3_r01 1152 +#define _INIT_CALL_PY_EXACT_ARGS_4_r01 1153 +#define _INSERT_NULL_r10 1154 +#define _INSTRUMENTED_FOR_ITER_r23 1155 +#define _INSTRUMENTED_INSTRUCTION_r00 1156 +#define _INSTRUMENTED_JUMP_FORWARD_r00 1157 +#define _INSTRUMENTED_JUMP_FORWARD_r11 1158 +#define _INSTRUMENTED_JUMP_FORWARD_r22 1159 +#define _INSTRUMENTED_JUMP_FORWARD_r33 1160 +#define _INSTRUMENTED_LINE_r00 1161 +#define _INSTRUMENTED_NOT_TAKEN_r00 1162 +#define _INSTRUMENTED_NOT_TAKEN_r11 1163 +#define _INSTRUMENTED_NOT_TAKEN_r22 1164 +#define _INSTRUMENTED_NOT_TAKEN_r33 1165 +#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r00 1166 +#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r10 1167 +#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r21 1168 +#define _INSTRUMENTED_POP_JUMP_IF_FALSE_r32 1169 +#define _INSTRUMENTED_POP_JUMP_IF_NONE_r10 1170 +#define _INSTRUMENTED_POP_JUMP_IF_NOT_NONE_r10 1171 +#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r00 1172 +#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r10 1173 +#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r21 1174 +#define _INSTRUMENTED_POP_JUMP_IF_TRUE_r32 1175 +#define _IS_NONE_r11 1176 +#define _IS_OP_r03 1177 +#define _IS_OP_r13 1178 +#define _IS_OP_r23 1179 +#define _ITER_CHECK_LIST_r02 1180 +#define _ITER_CHECK_LIST_r12 1181 +#define _ITER_CHECK_LIST_r22 1182 +#define _ITER_CHECK_LIST_r33 1183 +#define _ITER_CHECK_RANGE_r02 1184 +#define _ITER_CHECK_RANGE_r12 1185 +#define _ITER_CHECK_RANGE_r22 1186 +#define _ITER_CHECK_RANGE_r33 1187 +#define _ITER_CHECK_TUPLE_r02 1188 +#define _ITER_CHECK_TUPLE_r12 1189 +#define _ITER_CHECK_TUPLE_r22 1190 +#define _ITER_CHECK_TUPLE_r33 1191 +#define _ITER_JUMP_LIST_r02 1192 +#define _ITER_JUMP_LIST_r12 1193 +#define _ITER_JUMP_LIST_r22 1194 +#define _ITER_JUMP_LIST_r33 1195 +#define _ITER_JUMP_RANGE_r02 1196 +#define _ITER_JUMP_RANGE_r12 1197 +#define _ITER_JUMP_RANGE_r22 1198 +#define _ITER_JUMP_RANGE_r33 1199 +#define _ITER_JUMP_TUPLE_r02 1200 +#define _ITER_JUMP_TUPLE_r12 1201 +#define _ITER_JUMP_TUPLE_r22 1202 +#define _ITER_JUMP_TUPLE_r33 1203 +#define _ITER_NEXT_LIST_r23 1204 +#define _ITER_NEXT_LIST_TIER_TWO_r23 1205 +#define _ITER_NEXT_RANGE_r03 1206 +#define _ITER_NEXT_RANGE_r13 1207 +#define _ITER_NEXT_RANGE_r23 1208 +#define _ITER_NEXT_TUPLE_r03 1209 +#define _ITER_NEXT_TUPLE_r13 1210 +#define _ITER_NEXT_TUPLE_r23 1211 +#define _JUMP_BACKWARD_NO_INTERRUPT_r00 1212 +#define _JUMP_BACKWARD_NO_INTERRUPT_r11 1213 +#define _JUMP_BACKWARD_NO_INTERRUPT_r22 1214 +#define _JUMP_BACKWARD_NO_INTERRUPT_r33 1215 +#define _JUMP_TO_TOP_r00 1216 +#define _LIST_APPEND_r10 1217 +#define _LIST_EXTEND_r11 1218 +#define _LOAD_ATTR_r10 1219 +#define _LOAD_ATTR_CLASS_r11 1220 +#define _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_r11 1221 +#define _LOAD_ATTR_INSTANCE_VALUE_r02 1222 +#define _LOAD_ATTR_INSTANCE_VALUE_r12 1223 +#define _LOAD_ATTR_INSTANCE_VALUE_r23 1224 +#define _LOAD_ATTR_METHOD_LAZY_DICT_r02 1225 +#define _LOAD_ATTR_METHOD_LAZY_DICT_r12 1226 +#define _LOAD_ATTR_METHOD_LAZY_DICT_r23 1227 +#define _LOAD_ATTR_METHOD_NO_DICT_r02 1228 +#define _LOAD_ATTR_METHOD_NO_DICT_r12 1229 +#define _LOAD_ATTR_METHOD_NO_DICT_r23 1230 +#define _LOAD_ATTR_METHOD_WITH_VALUES_r02 1231 +#define _LOAD_ATTR_METHOD_WITH_VALUES_r12 1232 +#define _LOAD_ATTR_METHOD_WITH_VALUES_r23 1233 +#define _LOAD_ATTR_MODULE_r12 1234 +#define _LOAD_ATTR_NONDESCRIPTOR_NO_DICT_r11 1235 +#define _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES_r11 1236 +#define _LOAD_ATTR_PROPERTY_FRAME_r11 1237 +#define _LOAD_ATTR_SLOT_r02 1238 +#define _LOAD_ATTR_SLOT_r12 1239 +#define _LOAD_ATTR_SLOT_r23 1240 +#define _LOAD_ATTR_WITH_HINT_r12 1241 +#define _LOAD_BUILD_CLASS_r01 1242 +#define _LOAD_BYTECODE_r00 1243 +#define _LOAD_COMMON_CONSTANT_r01 1244 +#define _LOAD_COMMON_CONSTANT_r12 1245 +#define _LOAD_COMMON_CONSTANT_r23 1246 +#define _LOAD_CONST_r01 1247 +#define _LOAD_CONST_r12 1248 +#define _LOAD_CONST_r23 1249 +#define _LOAD_CONST_INLINE_r01 1250 +#define _LOAD_CONST_INLINE_r12 1251 +#define _LOAD_CONST_INLINE_r23 1252 +#define _LOAD_CONST_INLINE_BORROW_r01 1253 +#define _LOAD_CONST_INLINE_BORROW_r12 1254 +#define _LOAD_CONST_INLINE_BORROW_r23 1255 +#define _LOAD_DEREF_r01 1256 +#define _LOAD_FAST_r01 1257 +#define _LOAD_FAST_r12 1258 +#define _LOAD_FAST_r23 1259 +#define _LOAD_FAST_0_r01 1260 +#define _LOAD_FAST_0_r12 1261 +#define _LOAD_FAST_0_r23 1262 +#define _LOAD_FAST_1_r01 1263 +#define _LOAD_FAST_1_r12 1264 +#define _LOAD_FAST_1_r23 1265 +#define _LOAD_FAST_2_r01 1266 +#define _LOAD_FAST_2_r12 1267 +#define _LOAD_FAST_2_r23 1268 +#define _LOAD_FAST_3_r01 1269 +#define _LOAD_FAST_3_r12 1270 +#define _LOAD_FAST_3_r23 1271 +#define _LOAD_FAST_4_r01 1272 +#define _LOAD_FAST_4_r12 1273 +#define _LOAD_FAST_4_r23 1274 +#define _LOAD_FAST_5_r01 1275 +#define _LOAD_FAST_5_r12 1276 +#define _LOAD_FAST_5_r23 1277 +#define _LOAD_FAST_6_r01 1278 +#define _LOAD_FAST_6_r12 1279 +#define _LOAD_FAST_6_r23 1280 +#define _LOAD_FAST_7_r01 1281 +#define _LOAD_FAST_7_r12 1282 +#define _LOAD_FAST_7_r23 1283 +#define _LOAD_FAST_AND_CLEAR_r01 1284 +#define _LOAD_FAST_AND_CLEAR_r12 1285 +#define _LOAD_FAST_AND_CLEAR_r23 1286 +#define _LOAD_FAST_BORROW_r01 1287 +#define _LOAD_FAST_BORROW_r12 1288 +#define _LOAD_FAST_BORROW_r23 1289 +#define _LOAD_FAST_BORROW_0_r01 1290 +#define _LOAD_FAST_BORROW_0_r12 1291 +#define _LOAD_FAST_BORROW_0_r23 1292 +#define _LOAD_FAST_BORROW_1_r01 1293 +#define _LOAD_FAST_BORROW_1_r12 1294 +#define _LOAD_FAST_BORROW_1_r23 1295 +#define _LOAD_FAST_BORROW_2_r01 1296 +#define _LOAD_FAST_BORROW_2_r12 1297 +#define _LOAD_FAST_BORROW_2_r23 1298 +#define _LOAD_FAST_BORROW_3_r01 1299 +#define _LOAD_FAST_BORROW_3_r12 1300 +#define _LOAD_FAST_BORROW_3_r23 1301 +#define _LOAD_FAST_BORROW_4_r01 1302 +#define _LOAD_FAST_BORROW_4_r12 1303 +#define _LOAD_FAST_BORROW_4_r23 1304 +#define _LOAD_FAST_BORROW_5_r01 1305 +#define _LOAD_FAST_BORROW_5_r12 1306 +#define _LOAD_FAST_BORROW_5_r23 1307 +#define _LOAD_FAST_BORROW_6_r01 1308 +#define _LOAD_FAST_BORROW_6_r12 1309 +#define _LOAD_FAST_BORROW_6_r23 1310 +#define _LOAD_FAST_BORROW_7_r01 1311 +#define _LOAD_FAST_BORROW_7_r12 1312 +#define _LOAD_FAST_BORROW_7_r23 1313 +#define _LOAD_FAST_BORROW_LOAD_FAST_BORROW_r02 1314 +#define _LOAD_FAST_BORROW_LOAD_FAST_BORROW_r13 1315 +#define _LOAD_FAST_CHECK_r01 1316 +#define _LOAD_FAST_CHECK_r12 1317 +#define _LOAD_FAST_CHECK_r23 1318 +#define _LOAD_FAST_LOAD_FAST_r02 1319 +#define _LOAD_FAST_LOAD_FAST_r13 1320 +#define _LOAD_FROM_DICT_OR_DEREF_r11 1321 +#define _LOAD_FROM_DICT_OR_GLOBALS_r11 1322 +#define _LOAD_GLOBAL_r00 1323 +#define _LOAD_GLOBAL_BUILTINS_r01 1324 +#define _LOAD_GLOBAL_MODULE_r01 1325 +#define _LOAD_LOCALS_r01 1326 +#define _LOAD_LOCALS_r12 1327 +#define _LOAD_LOCALS_r23 1328 +#define _LOAD_NAME_r01 1329 +#define _LOAD_SMALL_INT_r01 1330 +#define _LOAD_SMALL_INT_r12 1331 +#define _LOAD_SMALL_INT_r23 1332 +#define _LOAD_SMALL_INT_0_r01 1333 +#define _LOAD_SMALL_INT_0_r12 1334 +#define _LOAD_SMALL_INT_0_r23 1335 +#define _LOAD_SMALL_INT_1_r01 1336 +#define _LOAD_SMALL_INT_1_r12 1337 +#define _LOAD_SMALL_INT_1_r23 1338 +#define _LOAD_SMALL_INT_2_r01 1339 +#define _LOAD_SMALL_INT_2_r12 1340 +#define _LOAD_SMALL_INT_2_r23 1341 +#define _LOAD_SMALL_INT_3_r01 1342 +#define _LOAD_SMALL_INT_3_r12 1343 +#define _LOAD_SMALL_INT_3_r23 1344 +#define _LOAD_SPECIAL_r00 1345 +#define _LOAD_SUPER_ATTR_ATTR_r31 1346 +#define _LOAD_SUPER_ATTR_METHOD_r32 1347 +#define _LOCK_OBJECT_r01 1348 +#define _LOCK_OBJECT_r11 1349 +#define _LOCK_OBJECT_r22 1350 +#define _LOCK_OBJECT_r33 1351 +#define _MAKE_CALLARGS_A_TUPLE_r33 1352 +#define _MAKE_CELL_r00 1353 +#define _MAKE_FUNCTION_r12 1354 +#define _MAKE_HEAP_SAFE_r01 1355 +#define _MAKE_HEAP_SAFE_r11 1356 +#define _MAKE_HEAP_SAFE_r22 1357 +#define _MAKE_HEAP_SAFE_r33 1358 +#define _MAKE_WARM_r00 1359 +#define _MAKE_WARM_r11 1360 +#define _MAKE_WARM_r22 1361 +#define _MAKE_WARM_r33 1362 +#define _MAP_ADD_r20 1363 +#define _MATCH_CLASS_r33 1364 +#define _MATCH_KEYS_r23 1365 +#define _MATCH_MAPPING_r02 1366 +#define _MATCH_MAPPING_r12 1367 +#define _MATCH_MAPPING_r23 1368 +#define _MATCH_SEQUENCE_r02 1369 +#define _MATCH_SEQUENCE_r12 1370 +#define _MATCH_SEQUENCE_r23 1371 +#define _MAYBE_EXPAND_METHOD_r00 1372 +#define _MAYBE_EXPAND_METHOD_KW_r11 1373 +#define _MONITOR_CALL_r00 1374 +#define _MONITOR_CALL_KW_r11 1375 +#define _MONITOR_JUMP_BACKWARD_r00 1376 +#define _MONITOR_JUMP_BACKWARD_r11 1377 +#define _MONITOR_JUMP_BACKWARD_r22 1378 +#define _MONITOR_JUMP_BACKWARD_r33 1379 +#define _MONITOR_RESUME_r00 1380 +#define _NOP_r00 1381 +#define _NOP_r11 1382 +#define _NOP_r22 1383 +#define _NOP_r33 1384 +#define _POP_EXCEPT_r10 1385 +#define _POP_ITER_r20 1386 +#define _POP_JUMP_IF_FALSE_r00 1387 +#define _POP_JUMP_IF_FALSE_r10 1388 +#define _POP_JUMP_IF_FALSE_r21 1389 +#define _POP_JUMP_IF_FALSE_r32 1390 +#define _POP_JUMP_IF_TRUE_r00 1391 +#define _POP_JUMP_IF_TRUE_r10 1392 +#define _POP_JUMP_IF_TRUE_r21 1393 +#define _POP_JUMP_IF_TRUE_r32 1394 +#define _POP_TOP_r10 1395 +#define _POP_TOP_FLOAT_r00 1396 +#define _POP_TOP_FLOAT_r10 1397 +#define _POP_TOP_FLOAT_r21 1398 +#define _POP_TOP_FLOAT_r32 1399 +#define _POP_TOP_INT_r00 1400 +#define _POP_TOP_INT_r10 1401 +#define _POP_TOP_INT_r21 1402 +#define _POP_TOP_INT_r32 1403 +#define _POP_TOP_NOP_r00 1404 +#define _POP_TOP_NOP_r10 1405 +#define _POP_TOP_NOP_r21 1406 +#define _POP_TOP_NOP_r32 1407 +#define _POP_TOP_OPARG_r00 1408 +#define _POP_TOP_UNICODE_r00 1409 +#define _POP_TOP_UNICODE_r10 1410 +#define _POP_TOP_UNICODE_r21 1411 +#define _POP_TOP_UNICODE_r32 1412 +#define _PUSH_EXC_INFO_r02 1413 +#define _PUSH_EXC_INFO_r12 1414 +#define _PUSH_EXC_INFO_r23 1415 +#define _PUSH_FRAME_r10 1416 +#define _PUSH_NULL_r01 1417 +#define _PUSH_NULL_r12 1418 +#define _PUSH_NULL_r23 1419 +#define _PUSH_NULL_CONDITIONAL_r00 1420 +#define _PY_FRAME_EX_r31 1421 +#define _PY_FRAME_GENERAL_r01 1422 +#define _PY_FRAME_KW_r11 1423 +#define _REPLACE_WITH_TRUE_r02 1424 +#define _REPLACE_WITH_TRUE_r12 1425 +#define _REPLACE_WITH_TRUE_r23 1426 +#define _RESUME_CHECK_r00 1427 +#define _RESUME_CHECK_r11 1428 +#define _RESUME_CHECK_r22 1429 +#define _RESUME_CHECK_r33 1430 +#define _RETURN_GENERATOR_r01 1431 +#define _RETURN_VALUE_r11 1432 +#define _SAVE_RETURN_OFFSET_r00 1433 +#define _SAVE_RETURN_OFFSET_r11 1434 +#define _SAVE_RETURN_OFFSET_r22 1435 +#define _SAVE_RETURN_OFFSET_r33 1436 +#define _SEND_r33 1437 +#define _SEND_GEN_FRAME_r33 1438 +#define _SETUP_ANNOTATIONS_r00 1439 +#define _SET_ADD_r10 1440 +#define _SET_FUNCTION_ATTRIBUTE_r01 1441 +#define _SET_FUNCTION_ATTRIBUTE_r11 1442 +#define _SET_FUNCTION_ATTRIBUTE_r21 1443 +#define _SET_FUNCTION_ATTRIBUTE_r32 1444 +#define _SET_IP_r00 1445 +#define _SET_IP_r11 1446 +#define _SET_IP_r22 1447 +#define _SET_IP_r33 1448 +#define _SET_UPDATE_r11 1449 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03 1450 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13 1451 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23 1452 +#define _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 1453 +#define _SPILL_OR_RELOAD_r01 1454 +#define _SPILL_OR_RELOAD_r02 1455 +#define _SPILL_OR_RELOAD_r03 1456 +#define _SPILL_OR_RELOAD_r10 1457 +#define _SPILL_OR_RELOAD_r12 1458 +#define _SPILL_OR_RELOAD_r13 1459 +#define _SPILL_OR_RELOAD_r20 1460 +#define _SPILL_OR_RELOAD_r21 1461 +#define _SPILL_OR_RELOAD_r23 1462 +#define _SPILL_OR_RELOAD_r30 1463 +#define _SPILL_OR_RELOAD_r31 1464 +#define _SPILL_OR_RELOAD_r32 1465 +#define _START_EXECUTOR_r00 1466 +#define _STORE_ATTR_r20 1467 +#define _STORE_ATTR_INSTANCE_VALUE_r21 1468 +#define _STORE_ATTR_SLOT_r21 1469 +#define _STORE_ATTR_WITH_HINT_r21 1470 +#define _STORE_DEREF_r10 1471 +#define _STORE_FAST_LOAD_FAST_r11 1472 +#define _STORE_FAST_STORE_FAST_r20 1473 +#define _STORE_GLOBAL_r10 1474 +#define _STORE_NAME_r10 1475 +#define _STORE_SLICE_r30 1476 +#define _STORE_SUBSCR_r30 1477 +#define _STORE_SUBSCR_DICT_r31 1478 +#define _STORE_SUBSCR_DICT_KNOWN_HASH_r31 1479 +#define _STORE_SUBSCR_LIST_INT_r32 1480 +#define _SWAP_r11 1481 +#define _SWAP_2_r02 1482 +#define _SWAP_2_r12 1483 +#define _SWAP_2_r22 1484 +#define _SWAP_2_r33 1485 +#define _SWAP_3_r03 1486 +#define _SWAP_3_r13 1487 +#define _SWAP_3_r23 1488 +#define _SWAP_3_r33 1489 +#define _SWAP_FAST_r01 1490 +#define _SWAP_FAST_r11 1491 +#define _SWAP_FAST_r22 1492 +#define _SWAP_FAST_r33 1493 +#define _SWAP_FAST_0_r01 1494 +#define _SWAP_FAST_0_r11 1495 +#define _SWAP_FAST_0_r22 1496 +#define _SWAP_FAST_0_r33 1497 +#define _SWAP_FAST_1_r01 1498 +#define _SWAP_FAST_1_r11 1499 +#define _SWAP_FAST_1_r22 1500 +#define _SWAP_FAST_1_r33 1501 +#define _SWAP_FAST_2_r01 1502 +#define _SWAP_FAST_2_r11 1503 +#define _SWAP_FAST_2_r22 1504 +#define _SWAP_FAST_2_r33 1505 +#define _SWAP_FAST_3_r01 1506 +#define _SWAP_FAST_3_r11 1507 +#define _SWAP_FAST_3_r22 1508 +#define _SWAP_FAST_3_r33 1509 +#define _SWAP_FAST_4_r01 1510 +#define _SWAP_FAST_4_r11 1511 +#define _SWAP_FAST_4_r22 1512 +#define _SWAP_FAST_4_r33 1513 +#define _SWAP_FAST_5_r01 1514 +#define _SWAP_FAST_5_r11 1515 +#define _SWAP_FAST_5_r22 1516 +#define _SWAP_FAST_5_r33 1517 +#define _SWAP_FAST_6_r01 1518 +#define _SWAP_FAST_6_r11 1519 +#define _SWAP_FAST_6_r22 1520 +#define _SWAP_FAST_6_r33 1521 +#define _SWAP_FAST_7_r01 1522 +#define _SWAP_FAST_7_r11 1523 +#define _SWAP_FAST_7_r22 1524 +#define _SWAP_FAST_7_r33 1525 +#define _TIER2_RESUME_CHECK_r00 1526 +#define _TIER2_RESUME_CHECK_r11 1527 +#define _TIER2_RESUME_CHECK_r22 1528 +#define _TIER2_RESUME_CHECK_r33 1529 +#define _TO_BOOL_r11 1530 +#define _TO_BOOL_BOOL_r01 1531 +#define _TO_BOOL_BOOL_r11 1532 +#define _TO_BOOL_BOOL_r22 1533 +#define _TO_BOOL_BOOL_r33 1534 +#define _TO_BOOL_INT_r02 1535 +#define _TO_BOOL_INT_r12 1536 +#define _TO_BOOL_INT_r23 1537 +#define _TO_BOOL_LIST_r02 1538 +#define _TO_BOOL_LIST_r12 1539 +#define _TO_BOOL_LIST_r23 1540 +#define _TO_BOOL_NONE_r01 1541 +#define _TO_BOOL_NONE_r11 1542 +#define _TO_BOOL_NONE_r22 1543 +#define _TO_BOOL_NONE_r33 1544 +#define _TO_BOOL_STR_r02 1545 +#define _TO_BOOL_STR_r12 1546 +#define _TO_BOOL_STR_r23 1547 +#define _TRACE_RECORD_r00 1548 +#define _UNARY_INVERT_r12 1549 +#define _UNARY_NEGATIVE_r12 1550 +#define _UNARY_NEGATIVE_FLOAT_INPLACE_r02 1551 +#define _UNARY_NEGATIVE_FLOAT_INPLACE_r12 1552 +#define _UNARY_NEGATIVE_FLOAT_INPLACE_r23 1553 +#define _UNARY_NOT_r01 1554 +#define _UNARY_NOT_r11 1555 +#define _UNARY_NOT_r22 1556 +#define _UNARY_NOT_r33 1557 +#define _UNPACK_EX_r10 1558 +#define _UNPACK_SEQUENCE_r10 1559 +#define _UNPACK_SEQUENCE_LIST_r10 1560 +#define _UNPACK_SEQUENCE_TUPLE_r10 1561 +#define _UNPACK_SEQUENCE_TWO_TUPLE_r12 1562 +#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE_r03 1563 +#define _UNPACK_SEQUENCE_UNIQUE_THREE_TUPLE_r13 1564 +#define _UNPACK_SEQUENCE_UNIQUE_TUPLE_r10 1565 +#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r02 1566 +#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r12 1567 +#define _UNPACK_SEQUENCE_UNIQUE_TWO_TUPLE_r23 1568 +#define _WITH_EXCEPT_START_r33 1569 +#define _YIELD_VALUE_r11 1570 +#define MAX_UOP_REGS_ID 1570 #ifdef __cplusplus } diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index 016bed17bf15aa..1a7ada0c8b2b0d 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -79,7 +79,7 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_POP_TOP_INT] = 0, [_POP_TOP_FLOAT] = 0, [_POP_TOP_UNICODE] = 0, - [_POP_TWO] = HAS_ESCAPES_FLAG, + [_POP_TOP_OPARG] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, [_PUSH_NULL] = HAS_PURE_FLAG, [_END_FOR] = HAS_ESCAPES_FLAG | HAS_NO_SAVE_IP_FLAG, [_POP_ITER] = HAS_ESCAPES_FLAG, @@ -209,7 +209,9 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_DICT_MERGE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_MAP_ADD] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_LOAD_SUPER_ATTR_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_LOAD_SUPER_ATTR_METHOD] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_GUARD_NOS_TYPE_VERSION] = HAS_EXIT_FLAG, + [_GUARD_LOAD_SUPER_ATTR_METHOD] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_LOAD_SUPER_ATTR_METHOD] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_LOAD_ATTR] = HAS_ARG_FLAG | HAS_NAME_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_GUARD_TYPE_VERSION] = HAS_EXIT_FLAG, [_GUARD_TYPE_VERSION_LOCKED] = HAS_EXIT_FLAG, @@ -301,16 +303,18 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_CALL_STR_1] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_TUPLE_1] = HAS_EXIT_FLAG, [_CALL_TUPLE_1] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, - [_CHECK_AND_ALLOCATE_OBJECT] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CHECK_OBJECT] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_ALLOCATE_OBJECT] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_CREATE_INIT_FRAME] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG, [_EXIT_INIT_CHECK] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, - [_CALL_BUILTIN_CLASS] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_GUARD_CALLABLE_BUILTIN_CLASS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, + [_CALL_BUILTIN_CLASS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_BUILTIN_O] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_BUILTIN_O] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_O] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_BUILTIN_FAST] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_BUILTIN_FAST] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_FAST] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_LEN] = HAS_EXIT_FLAG, [_CALL_LEN] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_ISINSTANCE] = HAS_EXIT_FLAG, @@ -322,14 +326,14 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_CHECK_RECURSION_LIMIT] = HAS_EXIT_FLAG, [_CALL_METHOD_DESCRIPTOR_O_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_METHOD_DESCRIPTOR_NOARGS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_NOARGS] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST] = HAS_ARG_FLAG | HAS_EXIT_FLAG, - [_CALL_METHOD_DESCRIPTOR_FAST] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_CALL_METHOD_DESCRIPTOR_FAST_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_CALL_METHOD_DESCRIPTOR_FAST_INLINE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_MAYBE_EXPAND_METHOD_KW] = HAS_ARG_FLAG | HAS_ESCAPES_FLAG, [_PY_FRAME_KW] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG, [_CHECK_FUNCTION_VERSION_KW] = HAS_ARG_FLAG | HAS_EXIT_FLAG, @@ -342,7 +346,7 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_PY_FRAME_EX] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG, [_CHECK_IS_NOT_PY_CALLABLE_EX] = HAS_EXIT_FLAG, [_CALL_FUNCTION_EX_NON_PY_GENERAL] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_MAKE_FUNCTION] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_MAKE_FUNCTION] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_SET_FUNCTION_ATTRIBUTE] = HAS_ARG_FLAG, [_RETURN_GENERATOR] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG | HAS_NEEDS_GUARD_IP_FLAG, [_BUILD_SLICE] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, @@ -379,23 +383,8 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_DYNAMIC_EXIT] = HAS_ESCAPES_FLAG, [_CHECK_VALIDITY] = HAS_DEOPT_FLAG, [_LOAD_CONST_INLINE] = HAS_PURE_FLAG, - [_POP_TOP_LOAD_CONST_INLINE] = HAS_ESCAPES_FLAG | HAS_PURE_FLAG, [_LOAD_CONST_INLINE_BORROW] = HAS_PURE_FLAG, - [_POP_CALL] = HAS_ESCAPES_FLAG, - [_POP_CALL_ONE] = HAS_ESCAPES_FLAG, - [_POP_CALL_TWO] = HAS_ESCAPES_FLAG, - [_POP_TOP_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG, - [_POP_TWO_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG, - [_POP_CALL_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG, - [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG, - [_INSERT_1_LOAD_CONST_INLINE] = 0, - [_INSERT_1_LOAD_CONST_INLINE_BORROW] = 0, - [_INSERT_2_LOAD_CONST_INLINE_BORROW] = 0, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW] = 0, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = 0, - [_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG, - [_LOAD_CONST_UNDER_INLINE] = 0, - [_LOAD_CONST_UNDER_INLINE_BORROW] = 0, [_START_EXECUTOR] = HAS_DEOPT_FLAG, [_MAKE_WARM] = 0, [_FATAL_ERROR] = 0, @@ -834,12 +823,12 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { 2, 3, _POP_TOP_UNICODE_r32 }, }, }, - [_POP_TWO] = { - .best = { 2, 2, 2, 2 }, + [_POP_TOP_OPARG] = { + .best = { 0, 0, 0, 0 }, .entries = { + { 0, 0, _POP_TOP_OPARG_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, - { 0, 2, _POP_TWO_r20 }, { -1, -1, -1 }, }, }, @@ -2004,6 +1993,24 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { 1, 3, _LOAD_SUPER_ATTR_ATTR_r31 }, }, }, + [_GUARD_NOS_TYPE_VERSION] = { + .best = { 0, 1, 2, 3 }, + .entries = { + { 2, 0, _GUARD_NOS_TYPE_VERSION_r02 }, + { 2, 1, _GUARD_NOS_TYPE_VERSION_r12 }, + { 2, 2, _GUARD_NOS_TYPE_VERSION_r22 }, + { 3, 3, _GUARD_NOS_TYPE_VERSION_r33 }, + }, + }, + [_GUARD_LOAD_SUPER_ATTR_METHOD] = { + .best = { 0, 1, 2, 3 }, + .entries = { + { 3, 0, _GUARD_LOAD_SUPER_ATTR_METHOD_r03 }, + { 3, 1, _GUARD_LOAD_SUPER_ATTR_METHOD_r13 }, + { 3, 2, _GUARD_LOAD_SUPER_ATTR_METHOD_r23 }, + { 3, 3, _GUARD_LOAD_SUPER_ATTR_METHOD_r33 }, + }, + }, [_LOAD_SUPER_ATTR_METHOD] = { .best = { 3, 3, 3, 3 }, .entries = { @@ -2832,10 +2839,19 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { 2, 3, _CALL_TUPLE_1_r32 }, }, }, - [_CHECK_AND_ALLOCATE_OBJECT] = { + [_CHECK_OBJECT] = { .best = { 0, 0, 0, 0 }, .entries = { - { 0, 0, _CHECK_AND_ALLOCATE_OBJECT_r00 }, + { 0, 0, _CHECK_OBJECT_r00 }, + { -1, -1, -1 }, + { -1, -1, -1 }, + { -1, -1, -1 }, + }, + }, + [_ALLOCATE_OBJECT] = { + .best = { 0, 0, 0, 0 }, + .entries = { + { 0, 0, _ALLOCATE_OBJECT_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -2859,10 +2875,19 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { -1, -1, -1 }, }, }, + [_GUARD_CALLABLE_BUILTIN_CLASS] = { + .best = { 0, 0, 0, 0 }, + .entries = { + { 0, 0, _GUARD_CALLABLE_BUILTIN_CLASS_r00 }, + { -1, -1, -1 }, + { -1, -1, -1 }, + { -1, -1, -1 }, + }, + }, [_CALL_BUILTIN_CLASS] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_BUILTIN_CLASS_r01 }, + { 0, 0, _CALL_BUILTIN_CLASS_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -2898,7 +2923,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_BUILTIN_FAST] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_BUILTIN_FAST_r01 }, + { 0, 0, _CALL_BUILTIN_FAST_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -2916,7 +2941,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_BUILTIN_FAST_WITH_KEYWORDS_r01 }, + { 0, 0, _CALL_BUILTIN_FAST_WITH_KEYWORDS_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3024,7 +3049,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r01 }, + { 0, 0, _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3033,7 +3058,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r01 }, + { 0, 0, _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3051,7 +3076,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_NOARGS] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_NOARGS_r01 }, + { 3, 0, _CALL_METHOD_DESCRIPTOR_NOARGS_r03 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3060,7 +3085,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r01 }, + { 3, 0, _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r03 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3078,7 +3103,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_FAST] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_FAST_r01 }, + { 0, 0, _CALL_METHOD_DESCRIPTOR_FAST_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3087,7 +3112,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_METHOD_DESCRIPTOR_FAST_INLINE] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_METHOD_DESCRIPTOR_FAST_INLINE_r01 }, + { 0, 0, _CALL_METHOD_DESCRIPTOR_FAST_INLINE_r00 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3205,7 +3230,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { .best = { 1, 1, 1, 1 }, .entries = { { -1, -1, -1 }, - { 1, 1, _MAKE_FUNCTION_r11 }, + { 2, 1, _MAKE_FUNCTION_r12 }, { -1, -1, -1 }, { -1, -1, -1 }, }, @@ -3534,15 +3559,6 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { -1, -1, -1 }, }, }, - [_POP_TOP_LOAD_CONST_INLINE] = { - .best = { 1, 1, 1, 1 }, - .entries = { - { -1, -1, -1 }, - { 1, 1, _POP_TOP_LOAD_CONST_INLINE_r11 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - }, - }, [_LOAD_CONST_INLINE_BORROW] = { .best = { 0, 1, 2, 2 }, .entries = { @@ -3552,105 +3568,6 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { -1, -1, -1 }, }, }, - [_POP_CALL] = { - .best = { 2, 2, 2, 2 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { 0, 2, _POP_CALL_r20 }, - { -1, -1, -1 }, - }, - }, - [_POP_CALL_ONE] = { - .best = { 3, 3, 3, 3 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - { 0, 3, _POP_CALL_ONE_r30 }, - }, - }, - [_POP_CALL_TWO] = { - .best = { 3, 3, 3, 3 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - { 0, 3, _POP_CALL_TWO_r30 }, - }, - }, - [_POP_TOP_LOAD_CONST_INLINE_BORROW] = { - .best = { 1, 1, 1, 1 }, - .entries = { - { -1, -1, -1 }, - { 1, 1, _POP_TOP_LOAD_CONST_INLINE_BORROW_r11 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - }, - }, - [_POP_TWO_LOAD_CONST_INLINE_BORROW] = { - .best = { 2, 2, 2, 2 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { 1, 2, _POP_TWO_LOAD_CONST_INLINE_BORROW_r21 }, - { -1, -1, -1 }, - }, - }, - [_POP_CALL_LOAD_CONST_INLINE_BORROW] = { - .best = { 2, 2, 2, 2 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { 1, 2, _POP_CALL_LOAD_CONST_INLINE_BORROW_r21 }, - { -1, -1, -1 }, - }, - }, - [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW] = { - .best = { 3, 3, 3, 3 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - { 1, 3, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31 }, - }, - }, - [_INSERT_1_LOAD_CONST_INLINE] = { - .best = { 0, 1, 2, 2 }, - .entries = { - { 2, 0, _INSERT_1_LOAD_CONST_INLINE_r02 }, - { 2, 1, _INSERT_1_LOAD_CONST_INLINE_r12 }, - { 3, 2, _INSERT_1_LOAD_CONST_INLINE_r23 }, - { -1, -1, -1 }, - }, - }, - [_INSERT_1_LOAD_CONST_INLINE_BORROW] = { - .best = { 0, 1, 2, 2 }, - .entries = { - { 2, 0, _INSERT_1_LOAD_CONST_INLINE_BORROW_r02 }, - { 2, 1, _INSERT_1_LOAD_CONST_INLINE_BORROW_r12 }, - { 3, 2, _INSERT_1_LOAD_CONST_INLINE_BORROW_r23 }, - { -1, -1, -1 }, - }, - }, - [_INSERT_2_LOAD_CONST_INLINE_BORROW] = { - .best = { 0, 1, 2, 2 }, - .entries = { - { 3, 0, _INSERT_2_LOAD_CONST_INLINE_BORROW_r03 }, - { 3, 1, _INSERT_2_LOAD_CONST_INLINE_BORROW_r13 }, - { 3, 2, _INSERT_2_LOAD_CONST_INLINE_BORROW_r23 }, - { -1, -1, -1 }, - }, - }, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW] = { - .best = { 0, 1, 2, 3 }, - .entries = { - { 2, 0, _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02 }, - { 2, 1, _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12 }, - { 2, 2, _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22 }, - { 2, 3, _SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32 }, - }, - }, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = { .best = { 0, 1, 2, 3 }, .entries = { @@ -3660,33 +3577,6 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { { 3, 3, _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 }, }, }, - [_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW] = { - .best = { 3, 3, 3, 3 }, - .entries = { - { -1, -1, -1 }, - { -1, -1, -1 }, - { -1, -1, -1 }, - { 1, 3, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31 }, - }, - }, - [_LOAD_CONST_UNDER_INLINE] = { - .best = { 0, 1, 2, 2 }, - .entries = { - { 2, 0, _LOAD_CONST_UNDER_INLINE_r02 }, - { 2, 1, _LOAD_CONST_UNDER_INLINE_r12 }, - { 3, 2, _LOAD_CONST_UNDER_INLINE_r23 }, - { -1, -1, -1 }, - }, - }, - [_LOAD_CONST_UNDER_INLINE_BORROW] = { - .best = { 0, 1, 2, 2 }, - .entries = { - { 2, 0, _LOAD_CONST_UNDER_INLINE_BORROW_r02 }, - { 2, 1, _LOAD_CONST_UNDER_INLINE_BORROW_r12 }, - { 3, 2, _LOAD_CONST_UNDER_INLINE_BORROW_r23 }, - { -1, -1, -1 }, - }, - }, [_START_EXECUTOR] = { .best = { 0, 0, 0, 0 }, .entries = { @@ -3984,7 +3874,7 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_POP_TOP_UNICODE_r10] = _POP_TOP_UNICODE, [_POP_TOP_UNICODE_r21] = _POP_TOP_UNICODE, [_POP_TOP_UNICODE_r32] = _POP_TOP_UNICODE, - [_POP_TWO_r20] = _POP_TWO, + [_POP_TOP_OPARG_r00] = _POP_TOP_OPARG, [_PUSH_NULL_r01] = _PUSH_NULL, [_PUSH_NULL_r12] = _PUSH_NULL, [_PUSH_NULL_r23] = _PUSH_NULL, @@ -4254,6 +4144,14 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_DICT_MERGE_r11] = _DICT_MERGE, [_MAP_ADD_r20] = _MAP_ADD, [_LOAD_SUPER_ATTR_ATTR_r31] = _LOAD_SUPER_ATTR_ATTR, + [_GUARD_NOS_TYPE_VERSION_r02] = _GUARD_NOS_TYPE_VERSION, + [_GUARD_NOS_TYPE_VERSION_r12] = _GUARD_NOS_TYPE_VERSION, + [_GUARD_NOS_TYPE_VERSION_r22] = _GUARD_NOS_TYPE_VERSION, + [_GUARD_NOS_TYPE_VERSION_r33] = _GUARD_NOS_TYPE_VERSION, + [_GUARD_LOAD_SUPER_ATTR_METHOD_r03] = _GUARD_LOAD_SUPER_ATTR_METHOD, + [_GUARD_LOAD_SUPER_ATTR_METHOD_r13] = _GUARD_LOAD_SUPER_ATTR_METHOD, + [_GUARD_LOAD_SUPER_ATTR_METHOD_r23] = _GUARD_LOAD_SUPER_ATTR_METHOD, + [_GUARD_LOAD_SUPER_ATTR_METHOD_r33] = _GUARD_LOAD_SUPER_ATTR_METHOD, [_LOAD_SUPER_ATTR_METHOD_r32] = _LOAD_SUPER_ATTR_METHOD, [_LOAD_ATTR_r10] = _LOAD_ATTR, [_GUARD_TYPE_VERSION_r01] = _GUARD_TYPE_VERSION, @@ -4456,16 +4354,18 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_GUARD_CALLABLE_TUPLE_1_r23] = _GUARD_CALLABLE_TUPLE_1, [_GUARD_CALLABLE_TUPLE_1_r33] = _GUARD_CALLABLE_TUPLE_1, [_CALL_TUPLE_1_r32] = _CALL_TUPLE_1, - [_CHECK_AND_ALLOCATE_OBJECT_r00] = _CHECK_AND_ALLOCATE_OBJECT, + [_CHECK_OBJECT_r00] = _CHECK_OBJECT, + [_ALLOCATE_OBJECT_r00] = _ALLOCATE_OBJECT, [_CREATE_INIT_FRAME_r01] = _CREATE_INIT_FRAME, [_EXIT_INIT_CHECK_r10] = _EXIT_INIT_CHECK, - [_CALL_BUILTIN_CLASS_r01] = _CALL_BUILTIN_CLASS, + [_GUARD_CALLABLE_BUILTIN_CLASS_r00] = _GUARD_CALLABLE_BUILTIN_CLASS, + [_CALL_BUILTIN_CLASS_r00] = _CALL_BUILTIN_CLASS, [_GUARD_CALLABLE_BUILTIN_O_r00] = _GUARD_CALLABLE_BUILTIN_O, [_CALL_BUILTIN_O_r03] = _CALL_BUILTIN_O, [_GUARD_CALLABLE_BUILTIN_FAST_r00] = _GUARD_CALLABLE_BUILTIN_FAST, - [_CALL_BUILTIN_FAST_r01] = _CALL_BUILTIN_FAST, + [_CALL_BUILTIN_FAST_r00] = _CALL_BUILTIN_FAST, [_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS_r00] = _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, - [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01] = _CALL_BUILTIN_FAST_WITH_KEYWORDS, + [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r00] = _CALL_BUILTIN_FAST_WITH_KEYWORDS, [_GUARD_CALLABLE_LEN_r03] = _GUARD_CALLABLE_LEN, [_GUARD_CALLABLE_LEN_r13] = _GUARD_CALLABLE_LEN, [_GUARD_CALLABLE_LEN_r23] = _GUARD_CALLABLE_LEN, @@ -4492,14 +4392,14 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_CHECK_RECURSION_LIMIT_r33] = _CHECK_RECURSION_LIMIT, [_CALL_METHOD_DESCRIPTOR_O_INLINE_r03] = _CALL_METHOD_DESCRIPTOR_O_INLINE, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00] = _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r01] = _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r01] = _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE, + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00] = _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r00] = _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS_r00] = _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS, - [_CALL_METHOD_DESCRIPTOR_NOARGS_r01] = _CALL_METHOD_DESCRIPTOR_NOARGS, - [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r01] = _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE, + [_CALL_METHOD_DESCRIPTOR_NOARGS_r03] = _CALL_METHOD_DESCRIPTOR_NOARGS, + [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r03] = _CALL_METHOD_DESCRIPTOR_NOARGS_INLINE, [_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_r00] = _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST, - [_CALL_METHOD_DESCRIPTOR_FAST_r01] = _CALL_METHOD_DESCRIPTOR_FAST, - [_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r01] = _CALL_METHOD_DESCRIPTOR_FAST_INLINE, + [_CALL_METHOD_DESCRIPTOR_FAST_r00] = _CALL_METHOD_DESCRIPTOR_FAST, + [_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r00] = _CALL_METHOD_DESCRIPTOR_FAST_INLINE, [_MAYBE_EXPAND_METHOD_KW_r11] = _MAYBE_EXPAND_METHOD_KW, [_PY_FRAME_KW_r11] = _PY_FRAME_KW, [_CHECK_FUNCTION_VERSION_KW_r11] = _CHECK_FUNCTION_VERSION_KW, @@ -4518,7 +4418,7 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_CHECK_IS_NOT_PY_CALLABLE_EX_r23] = _CHECK_IS_NOT_PY_CALLABLE_EX, [_CHECK_IS_NOT_PY_CALLABLE_EX_r33] = _CHECK_IS_NOT_PY_CALLABLE_EX, [_CALL_FUNCTION_EX_NON_PY_GENERAL_r31] = _CALL_FUNCTION_EX_NON_PY_GENERAL, - [_MAKE_FUNCTION_r11] = _MAKE_FUNCTION, + [_MAKE_FUNCTION_r12] = _MAKE_FUNCTION, [_SET_FUNCTION_ATTRIBUTE_r01] = _SET_FUNCTION_ATTRIBUTE, [_SET_FUNCTION_ATTRIBUTE_r11] = _SET_FUNCTION_ATTRIBUTE, [_SET_FUNCTION_ATTRIBUTE_r21] = _SET_FUNCTION_ATTRIBUTE, @@ -4630,41 +4530,13 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_LOAD_CONST_INLINE_r01] = _LOAD_CONST_INLINE, [_LOAD_CONST_INLINE_r12] = _LOAD_CONST_INLINE, [_LOAD_CONST_INLINE_r23] = _LOAD_CONST_INLINE, - [_POP_TOP_LOAD_CONST_INLINE_r11] = _POP_TOP_LOAD_CONST_INLINE, [_LOAD_CONST_INLINE_BORROW_r01] = _LOAD_CONST_INLINE_BORROW, [_LOAD_CONST_INLINE_BORROW_r12] = _LOAD_CONST_INLINE_BORROW, [_LOAD_CONST_INLINE_BORROW_r23] = _LOAD_CONST_INLINE_BORROW, - [_POP_CALL_r20] = _POP_CALL, - [_POP_CALL_ONE_r30] = _POP_CALL_ONE, - [_POP_CALL_TWO_r30] = _POP_CALL_TWO, - [_POP_TOP_LOAD_CONST_INLINE_BORROW_r11] = _POP_TOP_LOAD_CONST_INLINE_BORROW, - [_POP_TWO_LOAD_CONST_INLINE_BORROW_r21] = _POP_TWO_LOAD_CONST_INLINE_BORROW, - [_POP_CALL_LOAD_CONST_INLINE_BORROW_r21] = _POP_CALL_LOAD_CONST_INLINE_BORROW, - [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31] = _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, - [_INSERT_1_LOAD_CONST_INLINE_r02] = _INSERT_1_LOAD_CONST_INLINE, - [_INSERT_1_LOAD_CONST_INLINE_r12] = _INSERT_1_LOAD_CONST_INLINE, - [_INSERT_1_LOAD_CONST_INLINE_r23] = _INSERT_1_LOAD_CONST_INLINE, - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r02] = _INSERT_1_LOAD_CONST_INLINE_BORROW, - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r12] = _INSERT_1_LOAD_CONST_INLINE_BORROW, - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r23] = _INSERT_1_LOAD_CONST_INLINE_BORROW, - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r03] = _INSERT_2_LOAD_CONST_INLINE_BORROW, - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r13] = _INSERT_2_LOAD_CONST_INLINE_BORROW, - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r23] = _INSERT_2_LOAD_CONST_INLINE_BORROW, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02] = _SHUFFLE_2_LOAD_CONST_INLINE_BORROW, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12] = _SHUFFLE_2_LOAD_CONST_INLINE_BORROW, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22] = _SHUFFLE_2_LOAD_CONST_INLINE_BORROW, - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32] = _SHUFFLE_2_LOAD_CONST_INLINE_BORROW, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW, [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW, - [_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31] = _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, - [_LOAD_CONST_UNDER_INLINE_r02] = _LOAD_CONST_UNDER_INLINE, - [_LOAD_CONST_UNDER_INLINE_r12] = _LOAD_CONST_UNDER_INLINE, - [_LOAD_CONST_UNDER_INLINE_r23] = _LOAD_CONST_UNDER_INLINE, - [_LOAD_CONST_UNDER_INLINE_BORROW_r02] = _LOAD_CONST_UNDER_INLINE_BORROW, - [_LOAD_CONST_UNDER_INLINE_BORROW_r12] = _LOAD_CONST_UNDER_INLINE_BORROW, - [_LOAD_CONST_UNDER_INLINE_BORROW_r23] = _LOAD_CONST_UNDER_INLINE_BORROW, [_START_EXECUTOR_r00] = _START_EXECUTOR, [_MAKE_WARM_r00] = _MAKE_WARM, [_MAKE_WARM_r11] = _MAKE_WARM, @@ -4751,6 +4623,8 @@ const uint16_t _PyUop_SpillsAndReloads[4][4] = { }; const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { + [_ALLOCATE_OBJECT] = "_ALLOCATE_OBJECT", + [_ALLOCATE_OBJECT_r00] = "_ALLOCATE_OBJECT_r00", [_BINARY_OP] = "_BINARY_OP", [_BINARY_OP_r23] = "_BINARY_OP_r23", [_BINARY_OP_ADD_FLOAT] = "_BINARY_OP_ADD_FLOAT", @@ -4875,11 +4749,11 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_BUILD_TUPLE] = "_BUILD_TUPLE", [_BUILD_TUPLE_r01] = "_BUILD_TUPLE_r01", [_CALL_BUILTIN_CLASS] = "_CALL_BUILTIN_CLASS", - [_CALL_BUILTIN_CLASS_r01] = "_CALL_BUILTIN_CLASS_r01", + [_CALL_BUILTIN_CLASS_r00] = "_CALL_BUILTIN_CLASS_r00", [_CALL_BUILTIN_FAST] = "_CALL_BUILTIN_FAST", - [_CALL_BUILTIN_FAST_r01] = "_CALL_BUILTIN_FAST_r01", + [_CALL_BUILTIN_FAST_r00] = "_CALL_BUILTIN_FAST_r00", [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS", - [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01", + [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r00] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS_r00", [_CALL_BUILTIN_O] = "_CALL_BUILTIN_O", [_CALL_BUILTIN_O_r03] = "_CALL_BUILTIN_O_r03", [_CALL_FUNCTION_EX_NON_PY_GENERAL] = "_CALL_FUNCTION_EX_NON_PY_GENERAL", @@ -4900,17 +4774,17 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_CALL_LIST_APPEND_r23] = "_CALL_LIST_APPEND_r23", [_CALL_LIST_APPEND_r33] = "_CALL_LIST_APPEND_r33", [_CALL_METHOD_DESCRIPTOR_FAST] = "_CALL_METHOD_DESCRIPTOR_FAST", - [_CALL_METHOD_DESCRIPTOR_FAST_r01] = "_CALL_METHOD_DESCRIPTOR_FAST_r01", + [_CALL_METHOD_DESCRIPTOR_FAST_r00] = "_CALL_METHOD_DESCRIPTOR_FAST_r00", [_CALL_METHOD_DESCRIPTOR_FAST_INLINE] = "_CALL_METHOD_DESCRIPTOR_FAST_INLINE", - [_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r01] = "_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r01", + [_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r00] = "_CALL_METHOD_DESCRIPTOR_FAST_INLINE_r00", [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r01] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r01", + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_r00", [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE", - [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r01] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r01", + [_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r00] = "_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE_r00", [_CALL_METHOD_DESCRIPTOR_NOARGS] = "_CALL_METHOD_DESCRIPTOR_NOARGS", - [_CALL_METHOD_DESCRIPTOR_NOARGS_r01] = "_CALL_METHOD_DESCRIPTOR_NOARGS_r01", + [_CALL_METHOD_DESCRIPTOR_NOARGS_r03] = "_CALL_METHOD_DESCRIPTOR_NOARGS_r03", [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE] = "_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE", - [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r01] = "_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r01", + [_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r03] = "_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE_r03", [_CALL_METHOD_DESCRIPTOR_O] = "_CALL_METHOD_DESCRIPTOR_O", [_CALL_METHOD_DESCRIPTOR_O_r03] = "_CALL_METHOD_DESCRIPTOR_O_r03", [_CALL_METHOD_DESCRIPTOR_O_INLINE] = "_CALL_METHOD_DESCRIPTOR_O_INLINE", @@ -4926,8 +4800,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_CALL_TYPE_1_r12] = "_CALL_TYPE_1_r12", [_CALL_TYPE_1_r22] = "_CALL_TYPE_1_r22", [_CALL_TYPE_1_r32] = "_CALL_TYPE_1_r32", - [_CHECK_AND_ALLOCATE_OBJECT] = "_CHECK_AND_ALLOCATE_OBJECT", - [_CHECK_AND_ALLOCATE_OBJECT_r00] = "_CHECK_AND_ALLOCATE_OBJECT_r00", [_CHECK_ATTR_CLASS] = "_CHECK_ATTR_CLASS", [_CHECK_ATTR_CLASS_r01] = "_CHECK_ATTR_CLASS_r01", [_CHECK_ATTR_CLASS_r11] = "_CHECK_ATTR_CLASS_r11", @@ -4978,6 +4850,8 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_CHECK_METHOD_VERSION_r00] = "_CHECK_METHOD_VERSION_r00", [_CHECK_METHOD_VERSION_KW] = "_CHECK_METHOD_VERSION_KW", [_CHECK_METHOD_VERSION_KW_r11] = "_CHECK_METHOD_VERSION_KW_r11", + [_CHECK_OBJECT] = "_CHECK_OBJECT", + [_CHECK_OBJECT_r00] = "_CHECK_OBJECT_r00", [_CHECK_PEP_523] = "_CHECK_PEP_523", [_CHECK_PEP_523_r00] = "_CHECK_PEP_523_r00", [_CHECK_PEP_523_r11] = "_CHECK_PEP_523_r11", @@ -5178,6 +5052,8 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_GUARD_BIT_IS_UNSET_POP_7_r10] = "_GUARD_BIT_IS_UNSET_POP_7_r10", [_GUARD_BIT_IS_UNSET_POP_7_r21] = "_GUARD_BIT_IS_UNSET_POP_7_r21", [_GUARD_BIT_IS_UNSET_POP_7_r32] = "_GUARD_BIT_IS_UNSET_POP_7_r32", + [_GUARD_CALLABLE_BUILTIN_CLASS] = "_GUARD_CALLABLE_BUILTIN_CLASS", + [_GUARD_CALLABLE_BUILTIN_CLASS_r00] = "_GUARD_CALLABLE_BUILTIN_CLASS_r00", [_GUARD_CALLABLE_BUILTIN_FAST] = "_GUARD_CALLABLE_BUILTIN_FAST", [_GUARD_CALLABLE_BUILTIN_FAST_r00] = "_GUARD_CALLABLE_BUILTIN_FAST_r00", [_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS] = "_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS", @@ -5299,6 +5175,11 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_GUARD_KEYS_VERSION_r11] = "_GUARD_KEYS_VERSION_r11", [_GUARD_KEYS_VERSION_r22] = "_GUARD_KEYS_VERSION_r22", [_GUARD_KEYS_VERSION_r33] = "_GUARD_KEYS_VERSION_r33", + [_GUARD_LOAD_SUPER_ATTR_METHOD] = "_GUARD_LOAD_SUPER_ATTR_METHOD", + [_GUARD_LOAD_SUPER_ATTR_METHOD_r03] = "_GUARD_LOAD_SUPER_ATTR_METHOD_r03", + [_GUARD_LOAD_SUPER_ATTR_METHOD_r13] = "_GUARD_LOAD_SUPER_ATTR_METHOD_r13", + [_GUARD_LOAD_SUPER_ATTR_METHOD_r23] = "_GUARD_LOAD_SUPER_ATTR_METHOD_r23", + [_GUARD_LOAD_SUPER_ATTR_METHOD_r33] = "_GUARD_LOAD_SUPER_ATTR_METHOD_r33", [_GUARD_NOS_ANY_DICT] = "_GUARD_NOS_ANY_DICT", [_GUARD_NOS_ANY_DICT_r02] = "_GUARD_NOS_ANY_DICT_r02", [_GUARD_NOS_ANY_DICT_r12] = "_GUARD_NOS_ANY_DICT_r12", @@ -5349,6 +5230,11 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_GUARD_NOS_TUPLE_r12] = "_GUARD_NOS_TUPLE_r12", [_GUARD_NOS_TUPLE_r22] = "_GUARD_NOS_TUPLE_r22", [_GUARD_NOS_TUPLE_r33] = "_GUARD_NOS_TUPLE_r33", + [_GUARD_NOS_TYPE_VERSION] = "_GUARD_NOS_TYPE_VERSION", + [_GUARD_NOS_TYPE_VERSION_r02] = "_GUARD_NOS_TYPE_VERSION_r02", + [_GUARD_NOS_TYPE_VERSION_r12] = "_GUARD_NOS_TYPE_VERSION_r12", + [_GUARD_NOS_TYPE_VERSION_r22] = "_GUARD_NOS_TYPE_VERSION_r22", + [_GUARD_NOS_TYPE_VERSION_r33] = "_GUARD_NOS_TYPE_VERSION_r33", [_GUARD_NOS_UNICODE] = "_GUARD_NOS_UNICODE", [_GUARD_NOS_UNICODE_r02] = "_GUARD_NOS_UNICODE_r02", [_GUARD_NOS_UNICODE_r12] = "_GUARD_NOS_UNICODE_r12", @@ -5472,18 +5358,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_INIT_CALL_PY_EXACT_ARGS_3_r01] = "_INIT_CALL_PY_EXACT_ARGS_3_r01", [_INIT_CALL_PY_EXACT_ARGS_4] = "_INIT_CALL_PY_EXACT_ARGS_4", [_INIT_CALL_PY_EXACT_ARGS_4_r01] = "_INIT_CALL_PY_EXACT_ARGS_4_r01", - [_INSERT_1_LOAD_CONST_INLINE] = "_INSERT_1_LOAD_CONST_INLINE", - [_INSERT_1_LOAD_CONST_INLINE_r02] = "_INSERT_1_LOAD_CONST_INLINE_r02", - [_INSERT_1_LOAD_CONST_INLINE_r12] = "_INSERT_1_LOAD_CONST_INLINE_r12", - [_INSERT_1_LOAD_CONST_INLINE_r23] = "_INSERT_1_LOAD_CONST_INLINE_r23", - [_INSERT_1_LOAD_CONST_INLINE_BORROW] = "_INSERT_1_LOAD_CONST_INLINE_BORROW", - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r02] = "_INSERT_1_LOAD_CONST_INLINE_BORROW_r02", - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r12] = "_INSERT_1_LOAD_CONST_INLINE_BORROW_r12", - [_INSERT_1_LOAD_CONST_INLINE_BORROW_r23] = "_INSERT_1_LOAD_CONST_INLINE_BORROW_r23", - [_INSERT_2_LOAD_CONST_INLINE_BORROW] = "_INSERT_2_LOAD_CONST_INLINE_BORROW", - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r03] = "_INSERT_2_LOAD_CONST_INLINE_BORROW_r03", - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r13] = "_INSERT_2_LOAD_CONST_INLINE_BORROW_r13", - [_INSERT_2_LOAD_CONST_INLINE_BORROW_r23] = "_INSERT_2_LOAD_CONST_INLINE_BORROW_r23", [_INSERT_NULL] = "_INSERT_NULL", [_INSERT_NULL_r10] = "_INSERT_NULL_r10", [_IS_NONE] = "_IS_NONE", @@ -5575,14 +5449,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_LOAD_CONST_INLINE_BORROW_r01] = "_LOAD_CONST_INLINE_BORROW_r01", [_LOAD_CONST_INLINE_BORROW_r12] = "_LOAD_CONST_INLINE_BORROW_r12", [_LOAD_CONST_INLINE_BORROW_r23] = "_LOAD_CONST_INLINE_BORROW_r23", - [_LOAD_CONST_UNDER_INLINE] = "_LOAD_CONST_UNDER_INLINE", - [_LOAD_CONST_UNDER_INLINE_r02] = "_LOAD_CONST_UNDER_INLINE_r02", - [_LOAD_CONST_UNDER_INLINE_r12] = "_LOAD_CONST_UNDER_INLINE_r12", - [_LOAD_CONST_UNDER_INLINE_r23] = "_LOAD_CONST_UNDER_INLINE_r23", - [_LOAD_CONST_UNDER_INLINE_BORROW] = "_LOAD_CONST_UNDER_INLINE_BORROW", - [_LOAD_CONST_UNDER_INLINE_BORROW_r02] = "_LOAD_CONST_UNDER_INLINE_BORROW_r02", - [_LOAD_CONST_UNDER_INLINE_BORROW_r12] = "_LOAD_CONST_UNDER_INLINE_BORROW_r12", - [_LOAD_CONST_UNDER_INLINE_BORROW_r23] = "_LOAD_CONST_UNDER_INLINE_BORROW_r23", [_LOAD_DEREF] = "_LOAD_DEREF", [_LOAD_DEREF_r01] = "_LOAD_DEREF_r01", [_LOAD_FAST] = "_LOAD_FAST", @@ -5715,7 +5581,7 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_MAKE_CELL] = "_MAKE_CELL", [_MAKE_CELL_r00] = "_MAKE_CELL_r00", [_MAKE_FUNCTION] = "_MAKE_FUNCTION", - [_MAKE_FUNCTION_r11] = "_MAKE_FUNCTION_r11", + [_MAKE_FUNCTION_r12] = "_MAKE_FUNCTION_r12", [_MAKE_HEAP_SAFE] = "_MAKE_HEAP_SAFE", [_MAKE_HEAP_SAFE_r01] = "_MAKE_HEAP_SAFE_r01", [_MAKE_HEAP_SAFE_r11] = "_MAKE_HEAP_SAFE_r11", @@ -5749,18 +5615,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_NOP_r11] = "_NOP_r11", [_NOP_r22] = "_NOP_r22", [_NOP_r33] = "_NOP_r33", - [_POP_CALL] = "_POP_CALL", - [_POP_CALL_r20] = "_POP_CALL_r20", - [_POP_CALL_LOAD_CONST_INLINE_BORROW] = "_POP_CALL_LOAD_CONST_INLINE_BORROW", - [_POP_CALL_LOAD_CONST_INLINE_BORROW_r21] = "_POP_CALL_LOAD_CONST_INLINE_BORROW_r21", - [_POP_CALL_ONE] = "_POP_CALL_ONE", - [_POP_CALL_ONE_r30] = "_POP_CALL_ONE_r30", - [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW] = "_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", - [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31] = "_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW_r31", - [_POP_CALL_TWO] = "_POP_CALL_TWO", - [_POP_CALL_TWO_r30] = "_POP_CALL_TWO_r30", - [_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW] = "_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", - [_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31] = "_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31", [_POP_EXCEPT] = "_POP_EXCEPT", [_POP_EXCEPT_r10] = "_POP_EXCEPT_r10", [_POP_ITER] = "_POP_ITER", @@ -5777,24 +5631,18 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_POP_TOP_INT_r10] = "_POP_TOP_INT_r10", [_POP_TOP_INT_r21] = "_POP_TOP_INT_r21", [_POP_TOP_INT_r32] = "_POP_TOP_INT_r32", - [_POP_TOP_LOAD_CONST_INLINE] = "_POP_TOP_LOAD_CONST_INLINE", - [_POP_TOP_LOAD_CONST_INLINE_r11] = "_POP_TOP_LOAD_CONST_INLINE_r11", - [_POP_TOP_LOAD_CONST_INLINE_BORROW] = "_POP_TOP_LOAD_CONST_INLINE_BORROW", - [_POP_TOP_LOAD_CONST_INLINE_BORROW_r11] = "_POP_TOP_LOAD_CONST_INLINE_BORROW_r11", [_POP_TOP_NOP] = "_POP_TOP_NOP", [_POP_TOP_NOP_r00] = "_POP_TOP_NOP_r00", [_POP_TOP_NOP_r10] = "_POP_TOP_NOP_r10", [_POP_TOP_NOP_r21] = "_POP_TOP_NOP_r21", [_POP_TOP_NOP_r32] = "_POP_TOP_NOP_r32", + [_POP_TOP_OPARG] = "_POP_TOP_OPARG", + [_POP_TOP_OPARG_r00] = "_POP_TOP_OPARG_r00", [_POP_TOP_UNICODE] = "_POP_TOP_UNICODE", [_POP_TOP_UNICODE_r00] = "_POP_TOP_UNICODE_r00", [_POP_TOP_UNICODE_r10] = "_POP_TOP_UNICODE_r10", [_POP_TOP_UNICODE_r21] = "_POP_TOP_UNICODE_r21", [_POP_TOP_UNICODE_r32] = "_POP_TOP_UNICODE_r32", - [_POP_TWO] = "_POP_TWO", - [_POP_TWO_r20] = "_POP_TWO_r20", - [_POP_TWO_LOAD_CONST_INLINE_BORROW] = "_POP_TWO_LOAD_CONST_INLINE_BORROW", - [_POP_TWO_LOAD_CONST_INLINE_BORROW_r21] = "_POP_TWO_LOAD_CONST_INLINE_BORROW_r21", [_PUSH_EXC_INFO] = "_PUSH_EXC_INFO", [_PUSH_EXC_INFO_r02] = "_PUSH_EXC_INFO_r02", [_PUSH_EXC_INFO_r12] = "_PUSH_EXC_INFO_r12", @@ -5858,11 +5706,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_SET_IP_r33] = "_SET_IP_r33", [_SET_UPDATE] = "_SET_UPDATE", [_SET_UPDATE_r11] = "_SET_UPDATE_r11", - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW] = "_SHUFFLE_2_LOAD_CONST_INLINE_BORROW", - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02] = "_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r02", - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12] = "_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r12", - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22] = "_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r22", - [_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32] = "_SHUFFLE_2_LOAD_CONST_INLINE_BORROW_r32", [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW", [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03", [_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13", @@ -6121,8 +5964,8 @@ int _PyUop_num_popped(int opcode, int oparg) return 1; case _POP_TOP_UNICODE: return 1; - case _POP_TWO: - return 2; + case _POP_TOP_OPARG: + return oparg; case _PUSH_NULL: return 0; case _END_FOR: @@ -6381,6 +6224,10 @@ int _PyUop_num_popped(int opcode, int oparg) return 2; case _LOAD_SUPER_ATTR_ATTR: return 3; + case _GUARD_NOS_TYPE_VERSION: + return 0; + case _GUARD_LOAD_SUPER_ATTR_METHOD: + return 0; case _LOAD_SUPER_ATTR_METHOD: return 3; case _LOAD_ATTR: @@ -6565,14 +6412,18 @@ int _PyUop_num_popped(int opcode, int oparg) return 0; case _CALL_TUPLE_1: return 3; - case _CHECK_AND_ALLOCATE_OBJECT: + case _CHECK_OBJECT: + return 0; + case _ALLOCATE_OBJECT: return 0; case _CREATE_INIT_FRAME: return 2 + oparg; case _EXIT_INIT_CHECK: return 1; + case _GUARD_CALLABLE_BUILTIN_CLASS: + return 0; case _CALL_BUILTIN_CLASS: - return 2 + oparg; + return 0; case _GUARD_CALLABLE_BUILTIN_O: return 0; case _CALL_BUILTIN_O: @@ -6580,11 +6431,11 @@ int _PyUop_num_popped(int opcode, int oparg) case _GUARD_CALLABLE_BUILTIN_FAST: return 0; case _CALL_BUILTIN_FAST: - return 2 + oparg; + return 0; case _GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS: return 0; case _CALL_BUILTIN_FAST_WITH_KEYWORDS: - return 2 + oparg; + return 0; case _GUARD_CALLABLE_LEN: return 0; case _CALL_LEN: @@ -6608,9 +6459,9 @@ int _PyUop_num_popped(int opcode, int oparg) case _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return 0; case _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: - return 2 + oparg; + return 0; case _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE: - return 1 + oparg; + return 0; case _GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS: return 0; case _CALL_METHOD_DESCRIPTOR_NOARGS: @@ -6620,9 +6471,9 @@ int _PyUop_num_popped(int opcode, int oparg) case _GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST: return 0; case _CALL_METHOD_DESCRIPTOR_FAST: - return 2 + oparg; + return 0; case _CALL_METHOD_DESCRIPTOR_FAST_INLINE: - return 1 + oparg; + return 0; case _MAYBE_EXPAND_METHOD_KW: return 0; case _PY_FRAME_KW: @@ -6721,40 +6572,10 @@ int _PyUop_num_popped(int opcode, int oparg) return 0; case _LOAD_CONST_INLINE: return 0; - case _POP_TOP_LOAD_CONST_INLINE: - return 1; case _LOAD_CONST_INLINE_BORROW: return 0; - case _POP_CALL: - return 2; - case _POP_CALL_ONE: - return 3; - case _POP_CALL_TWO: - return 4; - case _POP_TOP_LOAD_CONST_INLINE_BORROW: - return 1; - case _POP_TWO_LOAD_CONST_INLINE_BORROW: - return 2; - case _POP_CALL_LOAD_CONST_INLINE_BORROW: - return 2; - case _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW: - return 3; - case _INSERT_1_LOAD_CONST_INLINE: - return 1; - case _INSERT_1_LOAD_CONST_INLINE_BORROW: - return 1; - case _INSERT_2_LOAD_CONST_INLINE_BORROW: - return 2; - case _SHUFFLE_2_LOAD_CONST_INLINE_BORROW: - return 3; case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW: return 3; - case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW: - return 4; - case _LOAD_CONST_UNDER_INLINE: - return 1; - case _LOAD_CONST_UNDER_INLINE_BORROW: - return 1; case _START_EXECUTOR: return 0; case _MAKE_WARM: diff --git a/Include/moduleobject.h b/Include/moduleobject.h index 90462f183acc36..c2fb1f85165f7d 100644 --- a/Include/moduleobject.h +++ b/Include/moduleobject.h @@ -125,6 +125,8 @@ PyAPI_FUNC(PyObject *) PyModule_FromSlotsAndSpec(const PyModuleDef_Slot *slots, PyAPI_FUNC(int) PyModule_Exec(PyObject *module); PyAPI_FUNC(int) PyModule_GetStateSize(PyObject *module, Py_ssize_t *result); PyAPI_FUNC(int) PyModule_GetToken(PyObject *module, void **result); +PyAPI_FUNC(void*) PyModule_GetState_DuringGC(PyObject*); +PyAPI_FUNC(int) PyModule_GetToken_DuringGC(PyObject *module, void **result); #endif #ifndef _Py_OPAQUE_PYOBJECT diff --git a/Include/object.h b/Include/object.h index cfa9d6cdece5ef..e33f92295fb771 100644 --- a/Include/object.h +++ b/Include/object.h @@ -779,6 +779,14 @@ PyAPI_FUNC(int) PyType_Freeze(PyTypeObject *type); #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15) PyAPI_FUNC(PyObject *) PyType_GetModuleByToken(PyTypeObject *type, const void *token); +PyAPI_FUNC(void *) PyObject_GetTypeData_DuringGC(PyObject *obj, + PyTypeObject *cls); +PyAPI_FUNC(void *) PyType_GetModuleState_DuringGC(PyTypeObject *); +PyAPI_FUNC(int) PyType_GetBaseByToken_DuringGC(PyTypeObject *, + void *, PyTypeObject **); +PyAPI_FUNC(PyObject *) PyType_GetModule_DuringGC(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GetModuleByToken_DuringGC(PyTypeObject *type, + const void *token); #endif #ifdef __cplusplus diff --git a/Include/patchlevel.h b/Include/patchlevel.h index 154bdb0721d3d1..9f5c36230a7e45 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -24,10 +24,10 @@ #define PY_MINOR_VERSION 15 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 7 +#define PY_RELEASE_SERIAL 8 /* Version as a string */ -#define PY_VERSION "3.15.0a7+" +#define PY_VERSION "3.15.0a8+" /*--end constants--*/ diff --git a/InternalDocs/string_interning.md b/InternalDocs/string_interning.md index 0913b1a3471ef4..829a27654a37d3 100644 --- a/InternalDocs/string_interning.md +++ b/InternalDocs/string_interning.md @@ -16,8 +16,8 @@ dynamic interning. The 256 possible one-character latin-1 strings, which can be retrieved with `_Py_LATIN1_CHR(c)`, are stored in statically allocated arrays, -`_PyRuntime.static_objects.strings.ascii` and -`_PyRuntime.static_objects.strings.latin1`. +`_PyRuntime.static_objects.singletons.strings.ascii` and +`_PyRuntime.static_objects.singletons.strings.latin1`. Longer singleton strings are marked in C source with `_Py_ID` (if the string is a valid C identifier fragment) or `_Py_STR` (if it needs a separate diff --git a/Lib/_colorize.py b/Lib/_colorize.py index 8361ddbea89716..478f81894911e7 100644 --- a/Lib/_colorize.py +++ b/Lib/_colorize.py @@ -223,6 +223,22 @@ class FancyCompleter(ThemeSection): str: str = ANSIColors.BOLD_GREEN +@dataclass(frozen=True, kw_only=True) +class HttpServer(ThemeSection): + error: str = ANSIColors.YELLOW + path: str = ANSIColors.CYAN + serving: str = ANSIColors.GREEN + size: str = ANSIColors.GREY + status_informational: str = ANSIColors.RESET + status_ok: str = ANSIColors.GREEN + status_redirect: str = ANSIColors.INTENSE_CYAN + status_client_error: str = ANSIColors.YELLOW + status_server_error: str = ANSIColors.RED + timestamp: str = ANSIColors.GREY + url: str = ANSIColors.CYAN + reset: str = ANSIColors.RESET + + @dataclass(frozen=True, kw_only=True) class LiveProfiler(ThemeSection): """Theme section for the live profiling TUI (Tachyon profiler). @@ -346,6 +362,18 @@ class Syntax(ThemeSection): reset: str = ANSIColors.RESET +@dataclass(frozen=True, kw_only=True) +class Timeit(ThemeSection): + timing: str = ANSIColors.CYAN + best: str = ANSIColors.BOLD_GREEN + per_loop: str = ANSIColors.GREEN + punctuation: str = ANSIColors.GREY + warning: str = ANSIColors.YELLOW + warning_worst: str = ANSIColors.MAGENTA + warning_best: str = ANSIColors.GREEN + reset: str = ANSIColors.RESET + + @dataclass(frozen=True, kw_only=True) class Traceback(ThemeSection): type: str = ANSIColors.BOLD_MAGENTA @@ -378,8 +406,10 @@ class Theme: argparse: Argparse = field(default_factory=Argparse) difflib: Difflib = field(default_factory=Difflib) fancycompleter: FancyCompleter = field(default_factory=FancyCompleter) + http_server: HttpServer = field(default_factory=HttpServer) live_profiler: LiveProfiler = field(default_factory=LiveProfiler) syntax: Syntax = field(default_factory=Syntax) + timeit: Timeit = field(default_factory=Timeit) traceback: Traceback = field(default_factory=Traceback) unittest: Unittest = field(default_factory=Unittest) @@ -389,8 +419,10 @@ def copy_with( argparse: Argparse | None = None, difflib: Difflib | None = None, fancycompleter: FancyCompleter | None = None, + http_server: HttpServer | None = None, live_profiler: LiveProfiler | None = None, syntax: Syntax | None = None, + timeit: Timeit | None = None, traceback: Traceback | None = None, unittest: Unittest | None = None, ) -> Self: @@ -403,8 +435,10 @@ def copy_with( argparse=argparse or self.argparse, difflib=difflib or self.difflib, fancycompleter=fancycompleter or self.fancycompleter, + http_server=http_server or self.http_server, live_profiler=live_profiler or self.live_profiler, syntax=syntax or self.syntax, + timeit=timeit or self.timeit, traceback=traceback or self.traceback, unittest=unittest or self.unittest, ) @@ -421,8 +455,10 @@ def no_colors(cls) -> Self: argparse=Argparse.no_colors(), difflib=Difflib.no_colors(), fancycompleter=FancyCompleter.no_colors(), + http_server=HttpServer.no_colors(), live_profiler=LiveProfiler.no_colors(), syntax=Syntax.no_colors(), + timeit=Timeit.no_colors(), traceback=Traceback.no_colors(), unittest=Unittest.no_colors(), ) diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py index 10127e58897a58..e79fbfa6bb0b38 100644 --- a/Lib/_pyrepl/commands.py +++ b/Lib/_pyrepl/commands.py @@ -22,6 +22,7 @@ from __future__ import annotations import os import time +from typing import TYPE_CHECKING # Categories of actions: # killing @@ -32,10 +33,11 @@ # finishing # [completion] +from .render import RenderedScreen from .trace import trace # types -if False: +if TYPE_CHECKING: from .historical_reader import HistoricalReader @@ -74,7 +76,7 @@ def kill_range(self, start: int, end: int) -> None: else: r.kill_ring.append(text) r.pos = start - r.dirty = True + r.invalidate_buffer(start) class YankCommand(Command): @@ -125,24 +127,27 @@ def do(self) -> None: r.arg = 10 * r.arg - d else: r.arg = 10 * r.arg + d - r.dirty = True + r.invalidate_prompt() class clear_screen(Command): def do(self) -> None: r = self.reader + trace("command.clear_screen") r.console.clear() - r.dirty = True + r.invalidate_full() class refresh(Command): def do(self) -> None: - self.reader.dirty = True + trace("command.refresh") + self.reader.invalidate_full() class repaint(Command): def do(self) -> None: - self.reader.dirty = True + trace("command.repaint") + self.reader.invalidate_full() self.reader.console.repaint() @@ -208,9 +213,10 @@ def do(self) -> None: repl = len(r.kill_ring[-1]) r.kill_ring.insert(0, r.kill_ring.pop()) t = r.kill_ring[-1] + start = r.pos - repl b[r.pos - repl : r.pos] = t r.pos = r.pos - repl + len(t) - r.dirty = True + r.invalidate_buffer(start) class interrupt(FinishCommand): @@ -242,8 +248,9 @@ def do(self) -> None: r.console.prepare() r.pos = p # r.posxy = 0, 0 # XXX this is invalid - r.dirty = True - r.console.screen = [] + r.invalidate_full() + trace("command.suspend sync_rendered_screen") + r.console.sync_rendered_screen(RenderedScreen.empty(), r.console.posxy) class up(MotionCommand): @@ -369,6 +376,7 @@ class self_insert(EditCommand): def do(self) -> None: r = self.reader text = self.event * r.get_arg() + start = r.pos r.insert(text) if r.paste_mode: data = "" @@ -376,7 +384,7 @@ def do(self) -> None: data += ev.data if data: r.insert(data) - r.last_refresh_cache.invalidated = True + r.invalidate_buffer(start) class insert_nl(EditCommand): @@ -400,20 +408,23 @@ def do(self) -> None: del b[s] b.insert(t, c) r.pos = t - r.dirty = True + r.invalidate_buffer(s) class backspace(EditCommand): def do(self) -> None: r = self.reader b = r.buffer + changed_from: int | None = None for i in range(r.get_arg()): if r.pos > 0: r.pos -= 1 del b[r.pos] - r.dirty = True + changed_from = r.pos if changed_from is None else min(changed_from, r.pos) else: self.reader.error("can't backspace at start") + if changed_from is not None: + r.invalidate_buffer(changed_from) class delete(EditCommand): @@ -431,12 +442,15 @@ def do(self) -> None: r.console.finish() raise EOFError + changed_from: int | None = None for i in range(r.get_arg()): if r.pos != len(b): del b[r.pos] - r.dirty = True + changed_from = r.pos if changed_from is None else min(changed_from, r.pos) else: self.reader.error("end of buffer") + if changed_from is not None: + r.invalidate_buffer(changed_from) class accept(FinishCommand): @@ -450,6 +464,7 @@ def do(self) -> None: with self.reader.suspend(): self.reader.msg = _sitebuiltins._Helper()() # type: ignore[assignment] + self.reader.invalidate_prompt() class invalid_key(Command): @@ -470,22 +485,24 @@ def do(self) -> None: from .pager import get_pager from site import gethistoryfile + # After the pager exits, the screen state is unknown (Unix may + # restore via alternate screen, Windows shows pager output). + # Clear and force a full redraw at the end for consistency. + self.reader.console.clear() + history = os.linesep.join(self.reader.history[:]) self.reader.console.restore() pager = get_pager() pager(history, gethistoryfile()) self.reader.console.prepare() - # We need to copy over the state so that it's consistent between - # console and reader, and console does not overwrite/append stuff - self.reader.console.screen = self.reader.screen.copy() - self.reader.console.posxy = self.reader.cxy + self.reader.invalidate_full() class paste_mode(Command): def do(self) -> None: self.reader.paste_mode = not self.reader.paste_mode - self.reader.dirty = True + self.reader.invalidate_prompt() class perform_bracketed_paste(Command): @@ -502,4 +519,3 @@ def do(self) -> None: s=time.time() - start, ) self.reader.insert(data.replace(done, "")) - self.reader.last_refresh_cache.invalidated = True diff --git a/Lib/_pyrepl/completing_reader.py b/Lib/_pyrepl/completing_reader.py index 39d0a8af5dfaea..f783e8db36b028 100644 --- a/Lib/_pyrepl/completing_reader.py +++ b/Lib/_pyrepl/completing_reader.py @@ -21,17 +21,18 @@ from __future__ import annotations from dataclasses import dataclass, field +from typing import TYPE_CHECKING import re from . import commands, console, reader +from .render import RenderLine, ScreenOverlay from .reader import Reader # types Command = commands.Command -TYPE_CHECKING = False if TYPE_CHECKING: - from .types import KeySpec, CommandName, CompletionAction + from .types import CommandName, CompletionAction, Keymap, KeySpec def prefix(wordlist: list[str], j: int = 0) -> str: @@ -175,6 +176,8 @@ def do(self) -> None: r.cmpltn_action = None # consumed if msg: r.msg = msg + r.cmpltn_message_visible = True + r.invalidate_message() else: # other input since last tab: cancel action r.cmpltn_action = None @@ -192,7 +195,8 @@ def do(self) -> None: completion = stripcolor(completions[0]) if completions_unchangable and len(completion) == len(stem): r.msg = "[ sole completion ]" - r.dirty = True + r.cmpltn_message_visible = True + r.invalidate_message() r.insert(completion[len(stem):]) else: clean_completions = [stripcolor(word) for word in completions] @@ -201,19 +205,23 @@ def do(self) -> None: r.insert(p) if last_is_completer: r.cmpltn_menu_visible = True - r.cmpltn_message_visible = False r.cmpltn_menu, r.cmpltn_menu_end = build_menu( r.console, completions, r.cmpltn_menu_end, r.use_brackets, r.sort_in_column) - r.dirty = True + if r.msg: + r.msg = "" + r.cmpltn_message_visible = False + r.invalidate_message() + r.invalidate_overlay() elif not r.cmpltn_menu_visible: - r.cmpltn_message_visible = True if stem + p in clean_completions: r.msg = "[ complete but not unique ]" - r.dirty = True + r.cmpltn_message_visible = True + r.invalidate_message() else: r.msg = "[ not unique ]" - r.dirty = True + r.cmpltn_message_visible = True + r.invalidate_message() if r.cmpltn_action: if r.msg and r.cmpltn_message_visible: @@ -223,7 +231,7 @@ def do(self) -> None: else: r.msg = r.cmpltn_action[0] r.cmpltn_message_visible = True - r.dirty = True + r.invalidate_message() class self_insert(commands.self_insert): @@ -243,6 +251,7 @@ def do(self) -> None: r.cmpltn_menu, r.cmpltn_menu_end = build_menu( r.console, completions, 0, r.use_brackets, r.sort_in_column) + r.invalidate_overlay() else: r.cmpltn_reset() @@ -272,7 +281,7 @@ def __post_init__(self) -> None: self.commands[c.__name__] = c self.commands[c.__name__.replace('_', '-')] = c - def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: + def collect_keymap(self) -> Keymap: return super().collect_keymap() + ( (r'\t', 'complete'),) @@ -281,25 +290,24 @@ def after_command(self, cmd: Command) -> None: if not isinstance(cmd, (complete, self_insert)): self.cmpltn_reset() - def calc_screen(self) -> list[str]: - screen = super().calc_screen() - if self.cmpltn_menu_visible: - # We display the completions menu below the current prompt - ly = self.lxy[1] + 1 - screen[ly:ly] = self.cmpltn_menu - # If we're not in the middle of multiline edit, don't append to screeninfo - # since that screws up the position calculation in pos2xy function. - # This is a hack to prevent the cursor jumping - # into the completions menu when pressing left or down arrow. - if self.pos != len(self.buffer): - self.screeninfo[ly:ly] = [(0, [])]*len(self.cmpltn_menu) - return screen + def get_screen_overlays(self) -> tuple[ScreenOverlay, ...]: + if not self.cmpltn_menu_visible: + return () + return ( + ScreenOverlay( + self.lxy[1] + 1, + tuple(RenderLine.from_rendered_text(line) for line in self.cmpltn_menu), + insert=True, + ), + ) def finish(self) -> None: super().finish() self.cmpltn_reset() def cmpltn_reset(self) -> None: + if getattr(self, "cmpltn_menu_visible", False): + self.invalidate_overlay() self.cmpltn_menu = [] self.cmpltn_menu_visible = False self.cmpltn_message_visible = False diff --git a/Lib/_pyrepl/console.py b/Lib/_pyrepl/console.py index e0535d50396316..2a53d5ff581fa2 100644 --- a/Lib/_pyrepl/console.py +++ b/Lib/_pyrepl/console.py @@ -19,23 +19,25 @@ from __future__ import annotations +import os import _colorize from abc import ABC, abstractmethod import ast import code import linecache -from dataclasses import dataclass, field -import os.path +from dataclasses import dataclass import re import sys +from typing import TYPE_CHECKING - -TYPE_CHECKING = False +from .render import RenderedScreen +from .trace import trace if TYPE_CHECKING: - from typing import IO - from typing import Callable + from typing import Callable, IO + + from .types import CursorXY @dataclass @@ -47,10 +49,17 @@ class Event: @dataclass class Console(ABC): - posxy: tuple[int, int] - screen: list[str] = field(default_factory=list) + posxy: CursorXY = (0, 0) height: int = 25 width: int = 80 + _redraw_debug_palette: tuple[str, ...] = ( + "\x1b[41m", + "\x1b[42m", + "\x1b[43m", + "\x1b[44m", + "\x1b[45m", + "\x1b[46m", + ) def __init__( self, @@ -71,8 +80,52 @@ def __init__( else: self.output_fd = f_out.fileno() + self.posxy = (0, 0) + self.height = 25 + self.width = 80 + self._rendered_screen = RenderedScreen.empty() + self._redraw_visual_cycle = 0 + + @property + def screen(self) -> list[str]: + return list(self._rendered_screen.screen_lines) + + def sync_rendered_screen( + self, + rendered_screen: RenderedScreen, + posxy: CursorXY | None = None, + ) -> None: + if posxy is None: + posxy = rendered_screen.cursor + self.posxy = posxy + self._rendered_screen = rendered_screen + trace( + "console.sync_rendered_screen lines={lines} cursor={cursor}", + lines=len(rendered_screen.composed_lines), + cursor=posxy, + ) + + def invalidate_render_state(self) -> None: + self._rendered_screen = RenderedScreen.empty() + trace("console.invalidate_render_state") + + def begin_redraw_visualization(self) -> str | None: + if "PYREPL_VISUALIZE_REDRAWS" not in os.environ: + return None + + palette = self._redraw_debug_palette + cycle = self._redraw_visual_cycle + style = palette[cycle % len(palette)] + self._redraw_visual_cycle = cycle + 1 + trace( + "console.begin_redraw_visualization cycle={cycle} style={style!r}", + cycle=cycle, + style=style, + ) + return style + @abstractmethod - def refresh(self, screen: list[str], xy: tuple[int, int]) -> None: ... + def refresh(self, rendered_screen: RenderedScreen) -> None: ... @abstractmethod def prepare(self) -> None: ... diff --git a/Lib/_pyrepl/content.py b/Lib/_pyrepl/content.py new file mode 100644 index 00000000000000..3cb22fee84b740 --- /dev/null +++ b/Lib/_pyrepl/content.py @@ -0,0 +1,136 @@ +from __future__ import annotations + +from dataclasses import dataclass + +from .utils import ColorSpan, StyleRef, THEME, iter_display_chars, unbracket, wlen + + +@dataclass(frozen=True, slots=True) +class ContentFragment: + """A single display character with its visual width and style. + + The body of ``>>> def greet`` becomes one fragment per character:: + + d e f g r e e t + ╰──┴──╯ ╰──┴──┴──┴──╯ + keyword (unstyled) + + e.g. ``ContentFragment("d", 1, StyleRef(tag="keyword"))``. + """ + + text: str + width: int + style: StyleRef = StyleRef() + + +@dataclass(frozen=True, slots=True) +class PromptContent: + """The prompt split into leading full-width lines and an inline portion. + + For the common ``">>> "`` prompt (no newlines):: + + >>> def greet(name): + ╰─╯ + text=">>> ", width=4, leading_lines=() + + If ``sys.ps1`` contains newlines, e.g. ``"Python 3.13\\n>>> "``:: + + Python 3.13 ← leading_lines[0] + >>> def greet(name): + ╰─╯ + text=">>> ", width=4 + """ + + leading_lines: tuple[ContentFragment, ...] + text: str + width: int + + +@dataclass(frozen=True, slots=True) +class SourceLine: + """One logical line from the editor buffer, before styling. + + Given this two-line input in the REPL:: + + >>> def greet(name): + ... return name + ▲ cursor + + The buffer ``"def greet(name):\\n return name"`` yields:: + + SourceLine(lineno=0, text="def greet(name):", + start_offset=0, has_newline=True) + SourceLine(lineno=1, text=" return name", + start_offset=17, cursor_index=14) + """ + + lineno: int + text: str + start_offset: int + has_newline: bool + cursor_index: int | None = None + + @property + def cursor_on_line(self) -> bool: + return self.cursor_index is not None + + +@dataclass(frozen=True, slots=True) +class ContentLine: + """A logical line paired with its prompt and styled body. + + For ``>>> def greet(name):``:: + + >>> def greet(name): + ╰─╯ ╰──────────────╯ + prompt body: one ContentFragment per character + """ + + source: SourceLine + prompt: PromptContent + body: tuple[ContentFragment, ...] + + +def process_prompt(prompt: str) -> PromptContent: + r"""Return prompt content with width measured without zero-width markup.""" + + prompt_text = unbracket(prompt, including_content=False) + visible_prompt = unbracket(prompt, including_content=True) + leading_lines: list[ContentFragment] = [] + + while "\n" in prompt_text: + leading_text, _, prompt_text = prompt_text.partition("\n") + visible_leading, _, visible_prompt = visible_prompt.partition("\n") + leading_lines.append(ContentFragment(leading_text, wlen(visible_leading))) + + return PromptContent(tuple(leading_lines), prompt_text, wlen(visible_prompt)) + + +def build_body_fragments( + buffer: str, + colors: list[ColorSpan] | None, + start_index: int, +) -> tuple[ContentFragment, ...]: + """Convert a line's text into styled content fragments.""" + # Two separate loops to avoid the THEME() call in the common uncolored path. + if colors is None: + return tuple( + ContentFragment( + styled_char.text, + styled_char.width, + StyleRef(), + ) + for styled_char in iter_display_chars(buffer, colors, start_index) + ) + + theme = THEME() + return tuple( + ContentFragment( + styled_char.text, + styled_char.width, + StyleRef.from_tag(styled_char.tag, theme[styled_char.tag]) + if styled_char.tag + else StyleRef(), + ) + for styled_char in iter_display_chars(buffer, colors, start_index) + ) diff --git a/Lib/_pyrepl/historical_reader.py b/Lib/_pyrepl/historical_reader.py index 5cc82690ae36fc..09b969d80bc231 100644 --- a/Lib/_pyrepl/historical_reader.py +++ b/Lib/_pyrepl/historical_reader.py @@ -90,7 +90,7 @@ def do(self) -> None: if r.get_unicode() != r.history[r.historyi]: r.buffer = list(r.history[r.historyi]) r.pos = len(r.buffer) - r.dirty = True + r.invalidate_buffer(0) class first_history(commands.Command): @@ -130,10 +130,11 @@ def do(self) -> None: o = len(r.yank_arg_yanked) else: o = 0 + start = r.pos - o b[r.pos - o : r.pos] = list(w) r.yank_arg_yanked = w r.pos += len(w) - o - r.dirty = True + r.invalidate_buffer(start) class forward_history_isearch(commands.Command): @@ -142,7 +143,7 @@ def do(self) -> None: r.isearch_direction = ISEARCH_DIRECTION_FORWARDS r.isearch_start = r.historyi, r.pos r.isearch_term = "" - r.dirty = True + r.invalidate_prompt() r.push_input_trans(r.isearch_trans) @@ -150,7 +151,7 @@ class reverse_history_isearch(commands.Command): def do(self) -> None: r = self.reader r.isearch_direction = ISEARCH_DIRECTION_BACKWARDS - r.dirty = True + r.invalidate_prompt() r.isearch_term = "" r.push_input_trans(r.isearch_trans) r.isearch_start = r.historyi, r.pos @@ -163,7 +164,7 @@ def do(self) -> None: r.pop_input_trans() r.select_item(r.isearch_start[0]) r.pos = r.isearch_start[1] - r.dirty = True + r.invalidate_prompt() class isearch_add_character(commands.Command): @@ -171,7 +172,7 @@ def do(self) -> None: r = self.reader b = r.buffer r.isearch_term += self.event[-1] - r.dirty = True + r.invalidate_prompt() p = r.pos + len(r.isearch_term) - 1 if b[p : p + 1] != [r.isearch_term[-1]]: r.isearch_next() @@ -182,7 +183,7 @@ def do(self) -> None: r = self.reader if len(r.isearch_term) > 0: r.isearch_term = r.isearch_term[:-1] - r.dirty = True + r.invalidate_prompt() else: r.error("nothing to rubout") @@ -207,7 +208,7 @@ def do(self) -> None: r.isearch_direction = ISEARCH_DIRECTION_NONE r.console.forgetinput() r.pop_input_trans() - r.dirty = True + r.invalidate_prompt() @dataclass @@ -278,8 +279,7 @@ def select_item(self, i: int) -> None: self.buffer = list(buf) self.historyi = i self.pos = len(self.buffer) - self.dirty = True - self.last_refresh_cache.invalidated = True + self.invalidate_buffer(0) def get_item(self, i: int) -> str: if i != len(self.history): @@ -357,7 +357,7 @@ def search_next(self, *, forwards: bool) -> None: if forwards and not match_prefix: self.pos = 0 self.buffer = [] - self.dirty = True + self.invalidate_buffer(0) else: self.error("not found") return diff --git a/Lib/_pyrepl/input.py b/Lib/_pyrepl/input.py index 21c24eb5cde3e3..2d65246c700f27 100644 --- a/Lib/_pyrepl/input.py +++ b/Lib/_pyrepl/input.py @@ -38,10 +38,11 @@ from abc import ABC, abstractmethod import unicodedata from collections import deque +from typing import TYPE_CHECKING # types -if False: +if TYPE_CHECKING: from .types import EventTuple diff --git a/Lib/_pyrepl/layout.py b/Lib/_pyrepl/layout.py new file mode 100644 index 00000000000000..6d854d1142dd9f --- /dev/null +++ b/Lib/_pyrepl/layout.py @@ -0,0 +1,268 @@ +"""Wrap content lines to the terminal width before rendering.""" + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Self + +from .content import ContentFragment, ContentLine +from .types import CursorXY, ScreenInfoRow + + +@dataclass(frozen=True, slots=True) +class LayoutRow: + """Metadata for one physical screen row. + + For the row ``>>> def greet(name):``:: + + >>> def greet(name): + ╰─╯ ╰──────────────╯ + 4 char_widths=(1,1,1,…) ← 16 entries + buffer_advance=17 ← includes the newline + """ + + prompt_width: int + char_widths: tuple[int, ...] + suffix_width: int = 0 + buffer_advance: int = 0 + + @property + def width(self) -> int: + return self.prompt_width + sum(self.char_widths) + self.suffix_width + + @property + def screeninfo(self) -> ScreenInfoRow: + widths = list(self.char_widths) + if self.suffix_width: + widths.append(self.suffix_width) + return self.prompt_width, widths + + +@dataclass(frozen=True, slots=True) +class LayoutMap: + """Mapping between buffer positions and screen coordinates. + + Single source of truth for cursor placement. Given:: + + >>> def greet(name): ← row 0, buffer_advance=17 + ... return name ← row 1, buffer_advance=15 + ▲cursor + + ``pos_to_xy(31)`` → ``(18, 1)``: prompt width 4 + 14 body chars. + """ + rows: tuple[LayoutRow, ...] + + @classmethod + def empty(cls) -> Self: + return cls((LayoutRow(0, ()),)) + + @property + def screeninfo(self) -> list[ScreenInfoRow]: + return [row.screeninfo for row in self.rows] + + def max_column(self, y: int) -> int: + return self.rows[y].width + + def max_row(self) -> int: + return len(self.rows) - 1 + + def pos_to_xy(self, pos: int) -> CursorXY: + if not self.rows: + return 0, 0 + + remaining = pos + for y, row in enumerate(self.rows): + if remaining <= len(row.char_widths): + # Prompt-only leading rows are terminal scenery, not real + # buffer positions. Treating them as real just manufactures + # bugs. + if remaining == 0 and not row.char_widths and row.buffer_advance == 0 and y < len(self.rows) - 1: + continue + x = row.prompt_width + for width in row.char_widths[:remaining]: + x += width + return x, y + remaining -= row.buffer_advance + last_row = self.rows[-1] + return last_row.width - last_row.suffix_width, len(self.rows) - 1 + + def xy_to_pos(self, x: int, y: int) -> int: + if not self.rows: + return 0 + + pos = 0 + for row in self.rows[:y]: + pos += row.buffer_advance + + row = self.rows[y] + cur_x = row.prompt_width + char_widths = row.char_widths + i = 0 + for i, width in enumerate(char_widths): + if cur_x >= x: + # Include trailing zero-width (combining) chars at this position + for trailing_width in char_widths[i:]: + if trailing_width == 0: + pos += 1 + else: + break + return pos + if width == 0: + pos += 1 + continue + cur_x += width + pos += 1 + return pos + + +@dataclass(frozen=True, slots=True) +class WrappedRow: + """One physical screen row after wrapping, ready for rendering. + + When a line overflows the terminal width, it splits into + multiple rows with a ``\\`` continuation marker:: + + >>> x = "a very long li\\ ← suffix="\\", suffix_width=1 + ne that wraps" ← prompt_text="" (continuation) + """ + prompt_text: str = "" + prompt_width: int = 0 + fragments: tuple[ContentFragment, ...] = () + layout_widths: tuple[int, ...] = () + suffix: str = "" + suffix_width: int = 0 + buffer_advance: int = 0 + + +@dataclass(frozen=True, slots=True) +class LayoutResult: + wrapped_rows: tuple[WrappedRow, ...] + layout_map: LayoutMap + line_end_offsets: tuple[int, ...] + + +def layout_content_lines( + lines: tuple[ContentLine, ...], + width: int, + start_offset: int, +) -> LayoutResult: + """Wrap content lines to fit *width* columns. + + A short line passes through as one ``WrappedRow``; a long line is + split at the column boundary with ``\\`` markers:: + + >>> short = 1 ← one WrappedRow + >>> x = "a long stri\\ ← two WrappedRows, first has suffix="\\" + ng" + """ + if width <= 0: + return LayoutResult((), LayoutMap(()), ()) + + offset = start_offset + wrapped_rows: list[WrappedRow] = [] + layout_rows: list[LayoutRow] = [] + line_end_offsets: list[int] = [] + + for line in lines: + newline_advance = int(line.source.has_newline) + for leading in line.prompt.leading_lines: + line_end_offsets.append(offset) + wrapped_rows.append( + WrappedRow( + fragments=(leading,), + ) + ) + layout_rows.append(LayoutRow(0, (), buffer_advance=0)) + + prompt_text = line.prompt.text + prompt_width = line.prompt.width + body = tuple(line.body) + body_widths = tuple(fragment.width for fragment in body) + + # Fast path: line fits on one row. + if not body_widths or (sum(body_widths) + prompt_width) < width: + offset += len(body) + newline_advance + line_end_offsets.append(offset) + wrapped_rows.append( + WrappedRow( + prompt_text=prompt_text, + prompt_width=prompt_width, + fragments=body, + layout_widths=body_widths, + buffer_advance=len(body) + newline_advance, + ) + ) + layout_rows.append( + LayoutRow( + prompt_width, + body_widths, + buffer_advance=len(body) + newline_advance, + ) + ) + continue + + # Slow path: line needs wrapping. + current_prompt = prompt_text + current_prompt_width = prompt_width + start = 0 + total = len(body) + while True: + # Find how many characters fit on this row. + index_to_wrap_before = 0 + column = 0 + for char_width in body_widths[start:]: + if column + char_width + current_prompt_width >= width: + break + index_to_wrap_before += 1 + column += char_width + + if index_to_wrap_before == 0 and start < total: + index_to_wrap_before = 1 # force progress + + at_line_end = (start + index_to_wrap_before) >= total + if at_line_end: + offset += index_to_wrap_before + newline_advance + suffix = "" + suffix_width = 0 + buffer_advance = index_to_wrap_before + newline_advance + else: + offset += index_to_wrap_before + suffix = "\\" + suffix_width = 1 + buffer_advance = index_to_wrap_before + + end = start + index_to_wrap_before + row_fragments = body[start:end] + row_widths = body_widths[start:end] + line_end_offsets.append(offset) + wrapped_rows.append( + WrappedRow( + prompt_text=current_prompt, + prompt_width=current_prompt_width, + fragments=row_fragments, + layout_widths=row_widths, + suffix=suffix, + suffix_width=suffix_width, + buffer_advance=buffer_advance, + ) + ) + layout_rows.append( + LayoutRow( + current_prompt_width, + row_widths, + suffix_width=suffix_width, + buffer_advance=buffer_advance, + ) + ) + + start = end + current_prompt = "" + current_prompt_width = 0 + if at_line_end: + break + + return LayoutResult( + tuple(wrapped_rows), + LayoutMap(tuple(layout_rows)), + tuple(line_end_offsets), + ) diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py index f35a99fb06a3f9..b8e1e425b0bb35 100644 --- a/Lib/_pyrepl/reader.py +++ b/Lib/_pyrepl/reader.py @@ -25,16 +25,40 @@ import _colorize from contextlib import contextmanager -from dataclasses import dataclass, field, fields +from dataclasses import dataclass, field, fields, replace +from typing import Self from . import commands, console, input -from .utils import wlen, unbracket, disp_str, gen_colors, THEME +from .content import ( + ContentFragment, + ContentLine, + SourceLine, + build_body_fragments, + process_prompt as build_prompt_content, +) +from .layout import LayoutMap, LayoutResult, LayoutRow, WrappedRow, layout_content_lines +from .render import RenderCell, RenderLine, RenderedScreen, ScreenOverlay +from .utils import ANSI_ESCAPE_SEQUENCE, THEME, StyleRef, wlen, gen_colors from .trace import trace # types Command = commands.Command -from .types import Callback, SimpleContextManager, KeySpec, CommandName +from .types import ( + Callback, + CommandName, + CursorXY, + Dimensions, + EventData, + KeySpec, + Keymap, + ScreenInfoRow, + SimpleContextManager, +) + +type CommandClass = type[Command] +type CommandInput = tuple[CommandName | CommandClass, EventData] +type PromptCellCacheKey = tuple[str, bool] # syntax classes @@ -52,8 +76,8 @@ def make_default_syntax_table() -> dict[str, int]: return st -def make_default_commands() -> dict[CommandName, type[Command]]: - result: dict[CommandName, type[Command]] = {} +def make_default_commands() -> dict[CommandName, CommandClass]: + result: dict[CommandName, CommandClass] = {} for v in vars(commands).values(): if isinstance(v, type) and issubclass(v, Command) and v.__name__[0].islower(): result[v.__name__] = v @@ -61,7 +85,7 @@ def make_default_commands() -> dict[CommandName, type[Command]]: return result -default_keymap: tuple[tuple[KeySpec, CommandName], ...] = tuple( +default_keymap: Keymap = tuple( [ (r"\C-a", "beginning-of-line"), (r"\C-b", "left"), @@ -131,6 +155,77 @@ def make_default_commands() -> dict[CommandName, type[Command]]: ) +@dataclass(frozen=True, slots=True) +class RefreshInvalidation: + """Which parts of the screen need to be recomputed on the next refresh.""" + + cursor_only: bool = False + buffer_from_pos: int | None = None + prompt: bool = False + layout: bool = False + theme: bool = False + message: bool = False + overlay: bool = False + full: bool = False + + @classmethod + def empty(cls) -> Self: + return cls() + + @property + def needs_screen_refresh(self) -> bool: + return any( + ( + self.buffer_from_pos is not None, + self.prompt, + self.layout, + self.theme, + self.message, + self.overlay, + self.full, + ) + ) + + @property + def is_cursor_only(self) -> bool: + return self.cursor_only and not self.needs_screen_refresh + + @property + def buffer_rebuild_from_pos(self) -> int | None: + if self.full or self.prompt or self.layout or self.theme: + return 0 + return self.buffer_from_pos + + def with_cursor(self) -> Self: + if self.needs_screen_refresh: + return self + return replace(self, cursor_only=True) + + def with_buffer(self, from_pos: int) -> Self: + current = from_pos + if self.buffer_from_pos is not None: + current = min(current, self.buffer_from_pos) + return replace(self, cursor_only=False, buffer_from_pos=current) + + def with_prompt(self) -> Self: + return replace(self, cursor_only=False, prompt=True) + + def with_layout(self) -> Self: + return replace(self, cursor_only=False, layout=True) + + def with_theme(self) -> Self: + return replace(self, cursor_only=False, theme=True) + + def with_message(self) -> Self: + return replace(self, cursor_only=False, message=True) + + def with_overlay(self) -> Self: + return replace(self, cursor_only=False, overlay=True) + + def with_full(self) -> Self: + return replace(self, cursor_only=False, full=True) + + @dataclass(slots=True) class Reader: """The Reader class implements the bare bones of a command reader, @@ -148,10 +243,9 @@ class Reader: * pos: A 0-based index into 'buffer' for where the insertion point is. - * screeninfo: - A list of screen position tuples. Each list element is a tuple - representing information on visible line length for a given line. - Allows for efficient skipping of color escape sequences. + * layout: + A mapping between buffer positions and rendered rows/columns. + It is the internal source of truth for cursor placement. * cxy, lxy: the position of the insertion point in screen ... * syntax_table: @@ -162,8 +256,6 @@ class Reader: * arg: The emacs-style prefix argument. It will be None if no such argument has been provided. - * dirty: - True if we need to refresh the display. * kill_ring: The emacs-style kill-ring; manipulated with yank & yank-pop * ps1, ps2, ps3, ps4: @@ -198,66 +290,88 @@ class Reader: kill_ring: list[list[str]] = field(default_factory=list) msg: str = "" arg: int | None = None - dirty: bool = False finished: bool = False paste_mode: bool = False - commands: dict[str, type[Command]] = field(default_factory=make_default_commands) - last_command: type[Command] | None = None + commands: dict[CommandName, CommandClass] = field(default_factory=make_default_commands) + last_command: CommandClass | None = None syntax_table: dict[str, int] = field(default_factory=make_default_syntax_table) - keymap: tuple[tuple[str, str], ...] = () + keymap: Keymap = () input_trans: input.KeymapTranslator = field(init=False) input_trans_stack: list[input.KeymapTranslator] = field(default_factory=list) - screen: list[str] = field(default_factory=list) - screeninfo: list[tuple[int, list[int]]] = field(init=False) - cxy: tuple[int, int] = field(init=False) - lxy: tuple[int, int] = field(init=False) - scheduled_commands: list[str] = field(default_factory=list) + rendered_screen: RenderedScreen = field(init=False) + layout: LayoutMap = field(init=False) + cxy: CursorXY = field(init=False) + lxy: CursorXY = field(init=False) + scheduled_commands: list[CommandName] = field(default_factory=list) can_colorize: bool = False threading_hook: Callback | None = None + invalidation: RefreshInvalidation = field(init=False) ## cached metadata to speed up screen refreshes @dataclass class RefreshCache: - screen: list[str] = field(default_factory=list) - screeninfo: list[tuple[int, list[int]]] = field(init=False) + """Previously computed render/layout data for incremental refresh.""" + + render_lines: list[RenderLine] = field(default_factory=list) + layout_rows: list[LayoutRow] = field(default_factory=list) line_end_offsets: list[int] = field(default_factory=list) - pos: int = field(init=False) - cxy: tuple[int, int] = field(init=False) - dimensions: tuple[int, int] = field(init=False) - invalidated: bool = False + pos: int = 0 + dimensions: Dimensions = (0, 0) def update_cache(self, reader: Reader, - screen: list[str], - screeninfo: list[tuple[int, list[int]]], + render_lines: list[RenderLine], + layout_rows: list[LayoutRow], + line_end_offsets: list[int], ) -> None: - self.screen = screen.copy() - self.screeninfo = screeninfo.copy() + self.render_lines = render_lines.copy() + self.layout_rows = layout_rows.copy() + self.line_end_offsets = line_end_offsets.copy() self.pos = reader.pos - self.cxy = reader.cxy self.dimensions = reader.console.width, reader.console.height - self.invalidated = False def valid(self, reader: Reader) -> bool: - if self.invalidated: - return False dimensions = reader.console.width, reader.console.height dimensions_changed = dimensions != self.dimensions return not dimensions_changed - def get_cached_location(self, reader: Reader) -> tuple[int, int]: - if self.invalidated: - raise ValueError("Cache is invalidated") - offset = 0 - earliest_common_pos = min(reader.pos, self.pos) + def get_cached_location( + self, + reader: Reader, + buffer_from_pos: int | None = None, + *, + reuse_full: bool = False, + ) -> tuple[int, int]: + """Return (buffer_offset, num_reusable_lines) for incremental refresh. + + Three paths: + - reuse_full (overlay/message-only): reuse all cached lines. + - buffer_from_pos=None (full rebuild): rewind to common cursor pos. + - explicit buffer_from_pos: reuse lines before that position. + """ + if reuse_full: + if self.line_end_offsets: + last_offset = self.line_end_offsets[-1] + if last_offset >= len(reader.buffer): + return last_offset, len(self.line_end_offsets) + return 0, 0 + if buffer_from_pos is None: + buffer_from_pos = min(reader.pos, self.pos) num_common_lines = len(self.line_end_offsets) while num_common_lines > 0: - offset = self.line_end_offsets[num_common_lines - 1] - if earliest_common_pos > offset: + candidate = self.line_end_offsets[num_common_lines - 1] + if buffer_from_pos > candidate: break num_common_lines -= 1 - else: - offset = 0 + # Prompt-only leading rows consume no buffer content. Reusing them + # in isolation causes the next incremental rebuild to emit them a + # second time. + while ( + num_common_lines > 0 + and self.layout_rows[num_common_lines - 1].buffer_advance == 0 + ): + num_common_lines -= 1 + offset = self.line_end_offsets[num_common_lines - 1] if num_common_lines else 0 return offset, num_common_lines last_refresh_cache: RefreshCache = field(default_factory=RefreshCache) @@ -270,131 +384,267 @@ def __post_init__(self) -> None: self.input_trans = input.KeymapTranslator( self.keymap, invalid_cls="invalid-key", character_cls="self-insert" ) - self.screeninfo = [(0, [])] + self.layout = LayoutMap.empty() self.cxy = self.pos2xy() self.lxy = (self.pos, 0) + self.rendered_screen = RenderedScreen.empty() self.can_colorize = _colorize.can_colorize() + self.invalidation = RefreshInvalidation.empty() - self.last_refresh_cache.screeninfo = self.screeninfo + self.last_refresh_cache.layout_rows = list(self.layout.rows) self.last_refresh_cache.pos = self.pos - self.last_refresh_cache.cxy = self.cxy + self.last_refresh_cache.dimensions = (0, 0) - def collect_keymap(self) -> tuple[tuple[KeySpec, CommandName], ...]: - return default_keymap + @property + def screen(self) -> list[str]: + return list(self.rendered_screen.screen_lines) - def calc_screen(self) -> list[str]: - """Translate changes in self.buffer into changes in self.console.screen.""" - # Since the last call to calc_screen: - # screen and screeninfo may differ due to a completion menu being shown - # pos and cxy may differ due to edits, cursor movements, or completion menus + @property + def screeninfo(self) -> list[ScreenInfoRow]: + return self.layout.screeninfo - # Lines that are above both the old and new cursor position can't have changed, - # unless the terminal has been resized (which might cause reflowing) or we've - # entered or left paste mode (which changes prompts, causing reflowing). + def collect_keymap(self) -> Keymap: + return default_keymap + + def calc_screen(self) -> RenderedScreen: + """Translate the editable buffer into a base rendered screen.""" num_common_lines = 0 offset = 0 if self.last_refresh_cache.valid(self): - offset, num_common_lines = self.last_refresh_cache.get_cached_location(self) - - screen = self.last_refresh_cache.screen - del screen[num_common_lines:] - - screeninfo = self.last_refresh_cache.screeninfo - del screeninfo[num_common_lines:] - - last_refresh_line_end_offsets = self.last_refresh_cache.line_end_offsets - del last_refresh_line_end_offsets[num_common_lines:] + if ( + self.invalidation.buffer_from_pos is None + and not ( + self.invalidation.full + or self.invalidation.prompt + or self.invalidation.layout + or self.invalidation.theme + ) + and (self.invalidation.message or self.invalidation.overlay) + ): + # Fast path: only overlays or messages changed. + offset, num_common_lines = self.last_refresh_cache.get_cached_location( + self, + reuse_full=True, + ) + assert not self.last_refresh_cache.line_end_offsets or ( + self.last_refresh_cache.line_end_offsets[-1] >= len(self.buffer) + ), "Buffer modified without invalidate_buffer() call" + else: + offset, num_common_lines = self.last_refresh_cache.get_cached_location( + self, + self._buffer_refresh_from_pos(), + ) + + base_render_lines = self.last_refresh_cache.render_lines[:num_common_lines] + layout_rows = self.last_refresh_cache.layout_rows[:num_common_lines] + last_refresh_line_end_offsets = self.last_refresh_cache.line_end_offsets[:num_common_lines] + + source_lines = self._build_source_lines(offset, num_common_lines) + content_lines = self._build_content_lines( + source_lines, + prompt_from_cache=bool(offset and self.buffer[offset - 1] != "\n"), + ) + layout_result = self._layout_content(content_lines, offset) + base_render_lines.extend(self._render_wrapped_rows(layout_result.wrapped_rows)) + layout_rows.extend(layout_result.layout_map.rows) + last_refresh_line_end_offsets.extend(layout_result.line_end_offsets) - pos = self.pos - pos -= offset + self.layout = LayoutMap(tuple(layout_rows)) + self.cxy = self.pos2xy() + if not source_lines: + # reuse_full path: _build_source_lines didn't run, + # so lxy wasn't updated. Derive it from the buffer. + self.lxy = self._compute_lxy() + self.last_refresh_cache.update_cache( + self, + base_render_lines, + layout_rows, + last_refresh_line_end_offsets, + ) + return RenderedScreen(tuple(base_render_lines), self.cxy) - prompt_from_cache = (offset and self.buffer[offset - 1] != "\n") + def _buffer_refresh_from_pos(self) -> int: + """Return buffer position from which to rebuild content. - if self.can_colorize: - colors = list(gen_colors(self.get_unicode())) + Returns 0 (full rebuild) when no incremental position is known. + """ + buffer_from_pos = self.invalidation.buffer_rebuild_from_pos + if buffer_from_pos is not None: + return buffer_from_pos + return 0 + + def _compute_lxy(self) -> CursorXY: + """Derive logical cursor (col, lineno) from the buffer and pos.""" + text = "".join(self.buffer[:self.pos]) + lineno = text.count("\n") + if lineno: + col = self.pos - text.rindex("\n") - 1 else: - colors = None - trace("colors = {colors}", colors=colors) + col = self.pos + return col, lineno + + def _build_source_lines( + self, + offset: int, + first_lineno: int, + ) -> tuple[SourceLine, ...]: + if offset == len(self.buffer) and (offset > 0 or first_lineno > 0): + return () + + pos = self.pos - offset lines = "".join(self.buffer[offset:]).split("\n") cursor_found = False lines_beyond_cursor = 0 - for ln, line in enumerate(lines, num_common_lines): + source_lines: list[SourceLine] = [] + current_offset = offset + + for line_index, line in enumerate(lines): + lineno = first_lineno + line_index + has_newline = line_index < len(lines) - 1 line_len = len(line) + cursor_index: int | None = None if 0 <= pos <= line_len: - self.lxy = pos, ln + cursor_index = pos + self.lxy = pos, lineno cursor_found = True elif cursor_found: lines_beyond_cursor += 1 if lines_beyond_cursor > self.console.height: - # No need to keep formatting lines. - # The console can't show them. break + + source_lines.append( + SourceLine( + lineno=lineno, + text=line, + start_offset=current_offset, + has_newline=has_newline, + cursor_index=cursor_index, + ) + ) + pos -= line_len + 1 + current_offset += line_len + (1 if has_newline else 0) + + return tuple(source_lines) + + def _build_content_lines( + self, + source_lines: tuple[SourceLine, ...], + *, + prompt_from_cache: bool, + ) -> tuple[ContentLine, ...]: + if self.can_colorize: + colors = list(gen_colors(self.get_unicode())) + else: + colors = None + trace("colors = {colors}", colors=colors) + + content_lines: list[ContentLine] = [] + for source_line in source_lines: if prompt_from_cache: - # Only the first line's prompt can come from the cache prompt_from_cache = False prompt = "" else: - prompt = self.get_prompt(ln, line_len >= pos >= 0) - while "\n" in prompt: - pre_prompt, _, prompt = prompt.partition("\n") - last_refresh_line_end_offsets.append(offset) - screen.append(pre_prompt) - screeninfo.append((0, [])) - pos -= line_len + 1 - prompt, prompt_len = self.process_prompt(prompt) - chars, char_widths = disp_str(line, colors, offset) - wrapcount = (sum(char_widths) + prompt_len) // self.console.width - if wrapcount == 0 or not char_widths: - offset += line_len + 1 # Takes all of the line plus the newline - last_refresh_line_end_offsets.append(offset) - screen.append(prompt + "".join(chars)) - screeninfo.append((prompt_len, char_widths)) - else: - pre = prompt - prelen = prompt_len - for wrap in range(wrapcount + 1): - index_to_wrap_before = 0 - column = 0 - for char_width in char_widths: - if column + char_width + prelen >= self.console.width: - break - index_to_wrap_before += 1 - column += char_width - if len(chars) > index_to_wrap_before: - offset += index_to_wrap_before - post = "\\" - after = [1] - else: - offset += index_to_wrap_before + 1 # Takes the newline - post = "" - after = [] - last_refresh_line_end_offsets.append(offset) - render = pre + "".join(chars[:index_to_wrap_before]) + post - render_widths = char_widths[:index_to_wrap_before] + after - screen.append(render) - screeninfo.append((prelen, render_widths)) - chars = chars[index_to_wrap_before:] - char_widths = char_widths[index_to_wrap_before:] - pre = "" - prelen = 0 - self.screeninfo = screeninfo - self.cxy = self.pos2xy() - if self.msg: - width = self.console.width - for mline in self.msg.split("\n"): - # If self.msg is larger than console width, make it fit - # TODO: try to split between words? - if not mline: - screen.append("") - screeninfo.append((0, [])) - continue - for r in range((len(mline) - 1) // width + 1): - screen.append(mline[r * width : (r + 1) * width]) - screeninfo.append((0, [])) - - self.last_refresh_cache.update_cache(self, screen, screeninfo) - return screen + prompt = self.get_prompt(source_line.lineno, source_line.cursor_on_line) + content_lines.append( + ContentLine( + source=source_line, + prompt=build_prompt_content(prompt), + body=build_body_fragments( + source_line.text, + colors, + source_line.start_offset, + ), + ) + ) + return tuple(content_lines) + + def _layout_content( + self, + content_lines: tuple[ContentLine, ...], + offset: int, + ) -> LayoutResult: + return layout_content_lines(content_lines, self.console.width, offset) + + def _render_wrapped_rows( + self, + wrapped_rows: tuple[WrappedRow, ...], + ) -> list[RenderLine]: + return [ + self._render_line( + row.prompt_text, + row.fragments, + row.suffix, + ) + for row in wrapped_rows + ] + + def _render_message_lines(self) -> tuple[RenderLine, ...]: + if not self.msg: + return () + width = self.console.width + render_lines: list[RenderLine] = [] + for message_line in self.msg.split("\n"): + # If self.msg is larger than console width, make it fit. + # TODO: try to split between words? + if not message_line: + render_lines.append(RenderLine.from_rendered_text("")) + continue + for offset in range(0, len(message_line), width): + render_lines.append( + RenderLine.from_rendered_text(message_line[offset : offset + width]) + ) + return tuple(render_lines) + + def get_screen_overlays(self) -> tuple[ScreenOverlay, ...]: + return () + + def compose_rendered_screen(self, base_screen: RenderedScreen) -> RenderedScreen: + overlays = list(self.get_screen_overlays()) + message_lines = self._render_message_lines() + if message_lines: + overlays.append(ScreenOverlay(len(base_screen.lines), message_lines)) + if not overlays: + return base_screen + return RenderedScreen(base_screen.lines, base_screen.cursor, tuple(overlays)) + + _prompt_cell_cache: dict[PromptCellCacheKey, tuple[RenderCell, ...]] = field( + init=False, default_factory=dict, repr=False + ) + + def _render_line( + self, + prefix: str, + fragments: tuple[ContentFragment, ...], + suffix: str = "", + ) -> RenderLine: + cells: list[RenderCell] = [] + if prefix: + cache_key = (prefix, self.can_colorize) + cached = self._prompt_cell_cache.get(cache_key) + if cached is None: + prompt_cells = RenderLine.from_rendered_text(prefix).cells + if self.can_colorize and prompt_cells and not ANSI_ESCAPE_SEQUENCE.search(prefix): + prompt_style = StyleRef.from_tag("prompt", THEME()["prompt"]) + prompt_cells = tuple( + RenderCell( + cell.text, + cell.width, + style=prompt_style if cell.text else cell.style, + controls=cell.controls, + ) + for cell in prompt_cells + ) + self._prompt_cell_cache[cache_key] = prompt_cells + cached = prompt_cells + cells.extend(cached) + cells.extend( + RenderCell(fragment.text, fragment.width, style=fragment.style) + for fragment in fragments + ) + if suffix: + cells.extend(RenderLine.from_rendered_text(suffix).cells) + return RenderLine.from_cells(cells) @staticmethod def process_prompt(prompt: str) -> tuple[str, int]: @@ -404,9 +654,8 @@ def process_prompt(prompt: str) -> tuple[str, int]: (\x01 and \x02) removed. The length ignores anything between those brackets as well as any ANSI escape sequences. """ - out_prompt = unbracket(prompt, including_content=False) - visible_prompt = unbracket(prompt, including_content=True) - return out_prompt, wlen(visible_prompt) + prompt_content = build_prompt_content(prompt) + return prompt_content.text, prompt_content.width def bow(self, p: int | None = None) -> int: """Return the 0-based index of the word break preceding p most @@ -468,10 +717,10 @@ def eol(self, p: int | None = None) -> int: def max_column(self, y: int) -> int: """Return the last x-offset for line y""" - return self.screeninfo[y][0] + sum(self.screeninfo[y][1]) + return self.layout.max_column(y) def max_row(self) -> int: - return len(self.screeninfo) - 1 + return self.layout.max_row() def get_arg(self, default: int = 1) -> int: """Return any prefix argument that the user has supplied, @@ -497,10 +746,6 @@ def get_prompt(self, lineno: int, cursor_on_line: bool) -> str: prompt = self.ps3 else: prompt = self.ps1 - - if self.can_colorize: - t = THEME() - prompt = f"{t.prompt}{prompt}{t.reset}" return prompt def push_input_trans(self, itrans: input.KeymapTranslator) -> None: @@ -512,65 +757,48 @@ def pop_input_trans(self) -> None: def setpos_from_xy(self, x: int, y: int) -> None: """Set pos according to coordinates x, y""" - pos = 0 - i = 0 - while i < y: - prompt_len, char_widths = self.screeninfo[i] - offset = len(char_widths) - in_wrapped_line = prompt_len + sum(char_widths) >= self.console.width - if in_wrapped_line: - pos += offset - 1 # -1 cause backslash is not in buffer - else: - pos += offset + 1 # +1 cause newline is in buffer - i += 1 - - j = 0 - cur_x = self.screeninfo[i][0] - while cur_x < x: - if self.screeninfo[i][1][j] == 0: - j += 1 # prevent potential future infinite loop - continue - cur_x += self.screeninfo[i][1][j] - j += 1 - pos += 1 + self.pos = self.layout.xy_to_pos(x, y) - self.pos = pos - - def pos2xy(self) -> tuple[int, int]: + def pos2xy(self) -> CursorXY: """Return the x, y coordinates of position 'pos'.""" + assert 0 <= self.pos <= len(self.buffer) + return self.layout.pos_to_xy(self.pos) + + def insert(self, text: str | list[str]) -> None: + """Insert 'text' at the insertion point.""" + start = self.pos + self.buffer[self.pos : self.pos] = list(text) + self.pos += len(text) + self.invalidate_buffer(start) - prompt_len, y = 0, 0 - char_widths: list[int] = [] - pos = self.pos - assert 0 <= pos <= len(self.buffer) + def invalidate_cursor(self) -> None: + self.invalidation = self.invalidation.with_cursor() - # optimize for the common case: typing at the end of the buffer - if pos == len(self.buffer) and len(self.screeninfo) > 0: - y = len(self.screeninfo) - 1 - prompt_len, char_widths = self.screeninfo[y] - return prompt_len + sum(char_widths), y + def invalidate_buffer(self, from_pos: int) -> None: + self.invalidation = self.invalidation.with_buffer(from_pos) - for prompt_len, char_widths in self.screeninfo: - offset = len(char_widths) - in_wrapped_line = prompt_len + sum(char_widths) >= self.console.width - if in_wrapped_line: - offset -= 1 # need to remove line-wrapping backslash + def invalidate_prompt(self) -> None: + self._prompt_cell_cache.clear() + self.invalidation = self.invalidation.with_prompt() - if offset >= pos: - break + def invalidate_layout(self) -> None: + self.invalidation = self.invalidation.with_layout() - if not in_wrapped_line: - offset += 1 # there's a newline in buffer + def invalidate_theme(self) -> None: + self._prompt_cell_cache.clear() + self.invalidation = self.invalidation.with_theme() - pos -= offset - y += 1 - return prompt_len + sum(char_widths[:pos]), y + def invalidate_message(self) -> None: + self.invalidation = self.invalidation.with_message() - def insert(self, text: str | list[str]) -> None: - """Insert 'text' at the insertion point.""" - self.buffer[self.pos : self.pos] = list(text) - self.pos += len(text) - self.dirty = True + def invalidate_overlay(self) -> None: + self.invalidation = self.invalidation.with_overlay() + + def invalidate_full(self) -> None: + self.invalidation = self.invalidation.with_full() + + def clear_invalidation(self) -> None: + self.invalidation = RefreshInvalidation.empty() def update_cursor(self) -> None: """Move the cursor to reflect changes in self.pos""" @@ -582,7 +810,7 @@ def after_command(self, cmd: Command) -> None: """This function is called to allow post command cleanup.""" if getattr(cmd, "kills_digit_arg", True): if self.arg is not None: - self.dirty = True + self.invalidate_prompt() self.arg = None def prepare(self) -> None: @@ -595,9 +823,15 @@ def prepare(self) -> None: self.finished = False del self.buffer[:] self.pos = 0 - self.dirty = True + self.layout = LayoutMap.empty() + self.cxy = self.pos2xy() + self.lxy = (self.pos, 0) + self.rendered_screen = RenderedScreen.empty() + self.invalidate_full() self.last_command = None - self.calc_screen() + base_screen = self.calc_screen() + self.rendered_screen = self.compose_rendered_screen(base_screen) + self.invalidation = RefreshInvalidation.empty() except BaseException: self.restore() raise @@ -606,7 +840,7 @@ def prepare(self) -> None: cmd = self.scheduled_commands.pop() self.do_cmd((cmd, [])) - def last_command_is(self, cls: type) -> bool: + def last_command_is(self, cls: CommandClass) -> bool: if not self.last_command: return False return issubclass(cls, self.last_command) @@ -642,21 +876,36 @@ def finish(self) -> None: def error(self, msg: str = "none") -> None: self.msg = "! " + msg + " " - self.dirty = True + self.invalidate_message() self.console.beep() def update_screen(self) -> None: - if self.dirty: + if self.invalidation.is_cursor_only: + self.update_cursor() + self.clear_invalidation() + elif self.invalidation.needs_screen_refresh: self.refresh() def refresh(self) -> None: """Recalculate and refresh the screen.""" + self.console.height, self.console.width = self.console.getheightwidth() # this call sets up self.cxy, so call it first. - self.screen = self.calc_screen() - self.console.refresh(self.screen, self.cxy) - self.dirty = False + base_screen = self.calc_screen() + rendered_screen = self.compose_rendered_screen(base_screen) + self.rendered_screen = rendered_screen + trace( + "reader.refresh cursor={cursor} lines={lines} " + "dims=({width},{height}) invalidation={invalidation}", + cursor=self.cxy, + lines=len(rendered_screen.composed_lines), + width=self.console.width, + height=self.console.height, + invalidation=self.invalidation, + ) + self.console.refresh(rendered_screen) + self.clear_invalidation() - def do_cmd(self, cmd: tuple[str, list[str]]) -> None: + def do_cmd(self, cmd: CommandInput) -> None: """`cmd` is a tuple of "event_name" and "event", which in the current implementation is always just the "buffer" which happens to be a list of single-character strings.""" @@ -673,13 +922,14 @@ def do_cmd(self, cmd: tuple[str, list[str]]) -> None: command.do() self.after_command(command) - - if self.dirty: - self.refresh() - else: - self.update_cursor() - - if not isinstance(cmd, commands.digit_arg): + if ( + not self.invalidation.needs_screen_refresh + and not self.invalidation.is_cursor_only + ): + self.invalidate_cursor() + self.update_screen() + + if command_type is not commands.digit_arg: self.last_command = command_type self.finished = bool(command.finish) @@ -712,7 +962,7 @@ def handle1(self, block: bool = True) -> bool: if self.msg: self.msg = "" - self.dirty = True + self.invalidate_message() while True: # We use the same timeout as in readline.c: 100ms @@ -729,9 +979,13 @@ def handle1(self, block: bool = True) -> bool: if event.evt == "key": self.input_trans.push(event) elif event.evt == "scroll": + self.invalidate_full() self.refresh() + return True elif event.evt == "resize": + self.invalidate_full() self.refresh() + return True else: translate = False diff --git a/Lib/_pyrepl/readline.py b/Lib/_pyrepl/readline.py index 8d3be37b4adeec..f8f1727d2a1d1f 100644 --- a/Lib/_pyrepl/readline.py +++ b/Lib/_pyrepl/readline.py @@ -277,7 +277,7 @@ class maybe_accept(commands.Command): def do(self) -> None: r: ReadlineAlikeReader r = self.reader # type: ignore[assignment] - r.dirty = True # this is needed to hide the completion menu, if visible + r.invalidate_overlay() # hide completion menu, if visible # if there are already several lines and the cursor # is not on the last one, always insert a new \n. @@ -337,7 +337,7 @@ def do(self) -> None: break r.pos -= repeat del b[r.pos : r.pos + repeat] - r.dirty = True + r.invalidate_buffer(r.pos) else: self.reader.error("can't backspace at start") @@ -413,8 +413,12 @@ def set_completer_delims(self, delimiters: Collection[str]) -> None: def get_completer_delims(self) -> str: return "".join(sorted(self.config.completer_delims)) - def _histline(self, line: str) -> str: + def _histline(self, line: str, *, sanitize_nuls: bool = False) -> str: line = line.rstrip("\n") + if "\0" in line: + if not sanitize_nuls: + raise ValueError("embedded null character") + line = line.replace("\0", "") return line def get_history_length(self) -> int: @@ -447,9 +451,12 @@ def read_history_file(self, filename: str = gethistoryfile()) -> None: if line.endswith("\r"): buffer.append(line+'\n') else: - line = self._histline(line) + line = self._histline(line, sanitize_nuls=True) if buffer: - line = self._histline("".join(buffer).replace("\r", "") + line) + line = self._histline( + "".join(buffer).replace("\r", "") + line, + sanitize_nuls=True, + ) del buffer[:] if line: history.append(line) diff --git a/Lib/_pyrepl/render.py b/Lib/_pyrepl/render.py new file mode 100644 index 00000000000000..b821f35d850825 --- /dev/null +++ b/Lib/_pyrepl/render.py @@ -0,0 +1,397 @@ +from __future__ import annotations + +from collections.abc import Iterable, Sequence +from dataclasses import dataclass, field +from typing import Literal, Protocol, Self + +from .utils import ANSI_ESCAPE_SEQUENCE, THEME, StyleRef, str_width +from .types import CursorXY + +type RenderStyle = StyleRef | str | None +type LineUpdateKind = Literal[ + "insert_char", + "replace_char", + "replace_span", + "delete_then_insert", + "rewrite_suffix", +] + + +class _ThemeSyntax(Protocol): + """Protocol for theme objects that map tag names to SGR escape strings.""" + def __getitem__(self, key: str, /) -> str: ... + + +@dataclass(frozen=True, slots=True) +class RenderCell: + """One terminal cell: a character, its column width, and SGR style. + + A screen row like ``>>> def`` is a sequence of cells:: + + > > > d e f + ╰─╯╰─╯╰─╯╰─╯╰─╯╰─╯╰─╯ + """ + + text: str + width: int + style: StyleRef = field(default_factory=StyleRef) + controls: tuple[str, ...] = () + + @property + def terminal_text(self) -> str: + return render_cells((self,)) + + +def _theme_style(theme: _ThemeSyntax, tag: str) -> str: + return theme[tag] + + +def _style_escape(style: StyleRef) -> str: + if style.sgr: + return style.sgr + if style.tag is None: + return "" + return _theme_style(THEME(), style.tag) + + +def _update_terminal_state(state: str, escape: str) -> str: + if escape in {"\x1b[0m", "\x1b[m"}: + return "" + return state + escape + + +def _cells_from_rendered_text(text: str) -> tuple[RenderCell, ...]: + if not text: + return () + + cells: list[RenderCell] = [] + pending_controls: list[str] = [] + active_sgr = "" + index = 0 + + def append_plain_text(segment: str) -> None: + nonlocal pending_controls + if not segment: + return + if pending_controls: + cells.append(RenderCell("", 0, controls=tuple(pending_controls))) + pending_controls = [] + for char in segment: + cells.append( + RenderCell( + char, + str_width(char), + style=StyleRef.from_sgr(active_sgr), + ) + ) + + for match in ANSI_ESCAPE_SEQUENCE.finditer(text): + append_plain_text(text[index : match.start()]) + escape = match.group(0) + if escape.endswith("m"): + active_sgr = _update_terminal_state(active_sgr, escape) + else: + pending_controls.append(escape) + index = match.end() + + append_plain_text(text[index:]) + if pending_controls: + cells.append(RenderCell("", 0, controls=tuple(pending_controls))) + + return tuple(cells) + + +@dataclass(frozen=True, slots=True) +class RenderLine: + """One physical screen row as a tuple of :class:`RenderCell` objects. + + ``text`` is the pre-rendered terminal string (characters + SGR escapes); + ``width`` is the total visible column count. + """ + + cells: tuple[RenderCell, ...] + text: str + width: int + + @classmethod + def from_cells(cls, cells: Iterable[RenderCell]) -> Self: + cell_tuple = tuple(cells) + return cls( + cells=cell_tuple, + text=render_cells(cell_tuple), + width=sum(cell.width for cell in cell_tuple), + ) + + @classmethod + def from_parts( + cls, + parts: Sequence[str], + widths: Sequence[int], + styles: Sequence[RenderStyle] | None = None, + ) -> Self: + if styles is None: + return cls.from_cells( + RenderCell(text, width) + for text, width in zip(parts, widths) + ) + + cells: list[RenderCell] = [] + for text, width, style in zip(parts, widths, styles): + if isinstance(style, StyleRef): + cells.append(RenderCell(text, width, style=style)) + elif style is None: + cells.append(RenderCell(text, width)) + else: + cells.append(RenderCell(text, width, style=StyleRef.from_tag(style))) + return cls.from_cells(cells) + + @classmethod + def from_rendered_text(cls, text: str) -> Self: + return cls.from_cells(_cells_from_rendered_text(text)) + + +@dataclass(frozen=True, slots=True) +class ScreenOverlay: + """An overlay that replaces or inserts lines at a screen position. + + If *insert* is True, lines are spliced in (shifting content down); + if False (default), lines replace existing content at *y*. + + Overlays are used to display tab completion menus and status messages. + For example, a tab-completion menu inserted below the input:: + + >>> os.path.j ← line 0 (base content) + join ← ScreenOverlay(y=1, insert=True) + junction ← (pushes remaining lines down) + ... ← line 1 (shifted down by 2) + """ + y: int + lines: tuple[RenderLine, ...] + insert: bool = False + + +@dataclass(frozen=True, slots=True) +class RenderedScreen: + """The complete screen state: content lines, cursor, and overlays. + + ``lines`` holds the base content; ``composed_lines`` is the final + result after overlays (completion menus, messages) are applied:: + + lines: composed_lines: + ┌──────────────────┐ ┌──────────────────┐ + │>>> os.path.j │ │>>> os.path.j │ + │... │ ──► │ join │ ← overlay + └──────────────────┘ │... │ + └──────────────────┘ + """ + + lines: tuple[RenderLine, ...] + cursor: CursorXY + overlays: tuple[ScreenOverlay, ...] = () + composed_lines: tuple[RenderLine, ...] = field(init=False, default=()) + + def __post_init__(self) -> None: + object.__setattr__(self, "composed_lines", self._compose()) + + def _compose(self) -> tuple[RenderLine, ...]: + """Apply overlays in tuple order; inserts shift subsequent positions.""" + if not self.overlays: + return self.lines + + lines = list(self.lines) + y_offset = 0 + for overlay in self.overlays: + adjusted_y = overlay.y + y_offset + assert adjusted_y >= 0, ( + f"Overlay y={overlay.y} with offset={y_offset} is negative; " + "overlays must be sorted by ascending y" + ) + if overlay.insert: + # Splice overlay lines in, pushing existing content down. + lines[adjusted_y:adjusted_y] = overlay.lines + y_offset += len(overlay.lines) + else: + # Replace existing lines at the overlay position. + target_len = adjusted_y + len(overlay.lines) + if len(lines) < target_len: + lines.extend([EMPTY_RENDER_LINE] * (target_len - len(lines))) + for index, line in enumerate(overlay.lines): + lines[adjusted_y + index] = line + return tuple(lines) + + @classmethod + def empty(cls) -> Self: + return cls((), (0, 0), ()) + + @classmethod + def from_screen_lines( + cls, + screen: Sequence[str], + cursor: CursorXY, + ) -> Self: + return cls( + tuple(RenderLine.from_rendered_text(line) for line in screen), + cursor, + (), + ) + + def with_overlay( + self, + y: int, + lines: Iterable[RenderLine], + ) -> Self: + return type(self)( + self.lines, + self.cursor, + self.overlays + (ScreenOverlay(y, tuple(lines)),), + ) + + @property + def screen_lines(self) -> tuple[str, ...]: + return tuple(line.text for line in self.composed_lines) + + +@dataclass(frozen=True, slots=True) +class LineDiff: + """The changed region between an old and new version of one screen row. + + When the user types ``e`` so the row changes from + ``>>> nam`` to ``>>> name``:: + + >>> n a m old + >>> n a m e new + ╰─╯ + start_cell=7, new_cells=("m","e"), old_cells=("m",) + """ + + start_cell: int + start_x: int + old_cells: tuple[RenderCell, ...] + new_cells: tuple[RenderCell, ...] + old_width: int + new_width: int + + @property + def old_text(self) -> str: + return render_cells(self.old_cells) + + @property + def new_text(self) -> str: + return render_cells(self.new_cells) + + @property + def old_changed_width(self) -> int: + return sum(cell.width for cell in self.old_cells) + + @property + def new_changed_width(self) -> int: + return sum(cell.width for cell in self.new_cells) + + +EMPTY_RENDER_LINE = RenderLine(cells=(), text="", width=0) + + +@dataclass(frozen=True, slots=True) +class LineUpdate: + kind: LineUpdateKind + y: int + start_cell: int + start_x: int + """Screen x-coordinate where the update begins. Used for cursor positioning.""" + cells: tuple[RenderCell, ...] + char_width: int = 0 + clear_eol: bool = False + reset_to_margin: bool = False + """If True, the console must resync the cursor position after writing + (needed when cells contain non-SGR escape sequences that may move the cursor).""" + text: str = field(init=False, default="") + + def __post_init__(self) -> None: + object.__setattr__(self, "text", render_cells(self.cells)) + + +def _controls_require_cursor_resync(controls: Sequence[str]) -> bool: + # Anything beyond SGR means the cursor may no longer be where we left it. + return any(not control.endswith("m") for control in controls) + + +def requires_cursor_resync(cells: Sequence[RenderCell]) -> bool: + return any(_controls_require_cursor_resync(cell.controls) for cell in cells) + + +def render_cells( + cells: Sequence[RenderCell], + visual_style: str | None = None, +) -> str: + """Render a sequence of cells into a terminal string with SGR escapes. + + Tracks the active SGR state to emit resets only when the style + actually changes, minimizing output bytes. + + If *visual_style* is given (used by redraw visualization), it is appended + to every cell's style. + """ + rendered: list[str] = [] + active_escape = "" + for cell in cells: + if cell.controls: + rendered.extend(cell.controls) + if not cell.text: + continue + + target_escape = _style_escape(cell.style) + if visual_style is not None: + target_escape += visual_style + if target_escape != active_escape: + if active_escape: + rendered.append("\x1b[0m") + if target_escape: + rendered.append(target_escape) + active_escape = target_escape + rendered.append(cell.text) + + if active_escape: + rendered.append("\x1b[0m") + return "".join(rendered) + + +def diff_render_lines(old: RenderLine, new: RenderLine) -> LineDiff | None: + if old == new: + return None + + prefix = 0 + start_x = 0 + max_prefix = min(len(old.cells), len(new.cells)) + while prefix < max_prefix and old.cells[prefix] == new.cells[prefix]: + # Stop at any cell with non-SGR controls, since those might affect + # cursor position and must be re-emitted. + if old.cells[prefix].controls: + break + start_x += old.cells[prefix].width + prefix += 1 + + old_suffix = len(old.cells) + new_suffix = len(new.cells) + while old_suffix > prefix and new_suffix > prefix: + old_cell = old.cells[old_suffix - 1] + new_cell = new.cells[new_suffix - 1] + if old_cell.controls or new_cell.controls or old_cell != new_cell: + break + old_suffix -= 1 + new_suffix -= 1 + + # Extend diff range to include trailing zero-width combining characters, + # so we never render a combining char without its base character. + while old_suffix < len(old.cells) and old.cells[old_suffix].width == 0: + old_suffix += 1 + while new_suffix < len(new.cells) and new.cells[new_suffix].width == 0: + new_suffix += 1 + + return LineDiff( + start_cell=prefix, + start_x=start_x, + old_cells=old.cells[prefix:old_suffix], + new_cells=new.cells[prefix:new_suffix], + old_width=old.width, + new_width=new.width, + ) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index 0da9f91baf6cfc..c169d0191bd833 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -161,7 +161,7 @@ def maybe_run_command(statement: str) -> bool: if r.input_trans is r.isearch_trans: r.do_cmd(("isearch-end", [""])) r.pos = len(r.get_unicode()) - r.dirty = True + r.invalidate_full() r.refresh() console.write("\nKeyboardInterrupt\n") console.resetbuffer() diff --git a/Lib/_pyrepl/trace.py b/Lib/_pyrepl/trace.py index 943ee12f964b29..395867805196a5 100644 --- a/Lib/_pyrepl/trace.py +++ b/Lib/_pyrepl/trace.py @@ -32,3 +32,9 @@ def trace(line: str, *k: object, **kw: object) -> None: line = line.format(*k, **kw) trace_file.write(line + "\n") trace_file.flush() + + +def trace_text(text: str, limit: int = 60) -> str: + if len(text) > limit: + text = text[:limit] + "..." + return repr(text) diff --git a/Lib/_pyrepl/types.py b/Lib/_pyrepl/types.py index e19607bf18e8b1..919763158eb123 100644 --- a/Lib/_pyrepl/types.py +++ b/Lib/_pyrepl/types.py @@ -4,7 +4,12 @@ type SimpleContextManager = Iterator[None] type KeySpec = str # like r"\C-c" type CommandName = str # like "interrupt" -type EventTuple = tuple[CommandName, str] +type EventData = list[str] +type EventTuple = tuple[CommandName, EventData] +type CursorXY = tuple[int, int] +type Dimensions = tuple[int, int] +type ScreenInfoRow = tuple[int, list[int]] +type Keymap = tuple[tuple[KeySpec, CommandName], ...] type Completer = Callable[[str, int], str | None] type CharBuffer = list[str] type CharWidths = list[int] diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index 937b5df6ff7d4c..9c4644db53e343 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -31,14 +31,25 @@ import time import types import platform +from collections.abc import Callable +from dataclasses import dataclass from fcntl import ioctl +from typing import TYPE_CHECKING, cast, overload from . import terminfo from .console import Console, Event from .fancy_termios import tcgetattr, tcsetattr, TermState -from .trace import trace +from .render import ( + EMPTY_RENDER_LINE, + LineUpdate, + RenderLine, + RenderedScreen, + requires_cursor_resync, + diff_render_lines, + render_cells, +) +from .trace import trace, trace_text from .unix_eventqueue import EventQueue -from .utils import wlen # declare posix optional to allow None assignment on other platforms posix: types.ModuleType | None @@ -47,14 +58,12 @@ except ImportError: posix = None -TYPE_CHECKING = False - # types if TYPE_CHECKING: - from typing import AbstractSet, IO, Literal, overload, cast -else: - overload = lambda func: None - cast = lambda typ, val: val + from typing import AbstractSet, IO, Literal + +type _MoveFunc = Callable[[int, int], None] +type _PendingWrite = tuple[str | bytes, bool] class InvalidTerminal(RuntimeError): @@ -140,7 +149,47 @@ def poll(self, timeout: float | None = None) -> list[int]: poll = MinimalPoll # type: ignore[assignment] +@dataclass(frozen=True, slots=True) +class UnixRefreshPlan: + """Instructions for updating the terminal after a screen change. + + After the user types ``e`` to complete ``name``:: + + Before: >>> def greet(nam|): + ▲ + LineUpdate here: insert_char "e" + + After: >>> def greet(name|): + ▲ + + Only the changed cells are sent to the terminal; unchanged rows + are skipped entirely. + """ + + grow_lines: int + """Number of blank lines to append at the bottom to accommodate new content.""" + use_tall_mode: bool + """Use absolute cursor addressing via ``cup`` instead of relative moves. + Activated when content exceeds one screen height.""" + offset: int + """Vertical scroll offset: the buffer row displayed at the top of the terminal window.""" + reverse_scroll: int + """Number of lines to scroll backwards (content moves down).""" + forward_scroll: int + """Number of lines to scroll forwards (content moves up).""" + line_updates: tuple[LineUpdate, ...] + cleared_lines: tuple[int, ...] + """Row indices to erase (old content with no replacement).""" + rendered_screen: RenderedScreen + cursor: tuple[int, int] + + class UnixConsole(Console): + __buffer: list[_PendingWrite] + __gone_tall: bool + __move: _MoveFunc + __offset: int + def __init__( self, f_in: IO[bytes] | int = 0, @@ -219,7 +268,7 @@ def _my_getstr(cap: str, optional: bool = False) -> bytes | None: self.event_queue = EventQueue( self.input_fd, self.encoding, self.terminfo ) - self.cursor_visible = 1 + self.cursor_visible = True signal.signal(signal.SIGCONT, self._sigcont_handler) @@ -239,34 +288,50 @@ def change_encoding(self, encoding: str) -> None: """ self.encoding = encoding - def refresh(self, screen, c_xy): + def refresh(self, rendered_screen: RenderedScreen) -> None: """ Refresh the console screen. Parameters: - - screen (list): List of strings representing the screen contents. - - c_xy (tuple): Cursor position (x, y) on the screen. + - rendered_screen: Structured rendered screen contents and cursor. """ + c_xy = rendered_screen.cursor + trace( + "unix.refresh start cursor={cursor} lines={lines} prev_lines={prev_lines} " + "offset={offset} posxy={posxy}", + cursor=c_xy, + lines=len(rendered_screen.composed_lines), + prev_lines=len(self._rendered_screen.composed_lines), + offset=self.__offset, + posxy=self.posxy, + ) + plan = self.__plan_refresh(rendered_screen, c_xy) + self.__apply_refresh_plan(plan) + + def __plan_refresh( + self, + rendered_screen: RenderedScreen, + c_xy: tuple[int, int], + ) -> UnixRefreshPlan: cx, cy = c_xy - if not self.__gone_tall: - while len(self.screen) < min(len(screen), self.height): - self.__hide_cursor() - if self.screen: - self.__move(0, len(self.screen) - 1) - self.__write("\n") - self.posxy = 0, len(self.screen) - self.screen.append("") - else: - while len(self.screen) < len(screen): - self.screen.append("") + height = self.height + old_offset = offset = self.__offset + prev_composed = self._rendered_screen.composed_lines + previous_lines = list(prev_composed) + next_lines = list(rendered_screen.composed_lines) + line_count = len(next_lines) - if len(screen) > self.height: - self.__gone_tall = 1 - self.__move = self.__move_tall + grow_lines = 0 + if not self.__gone_tall: + grow_lines = max( + min(line_count, height) - len(prev_composed), + 0, + ) + previous_lines.extend([EMPTY_RENDER_LINE] * grow_lines) + elif len(previous_lines) < line_count: + previous_lines.extend([EMPTY_RENDER_LINE] * (line_count - len(previous_lines))) - px, py = self.posxy - old_offset = offset = self.__offset - height = self.height + use_tall_mode = self.__gone_tall or line_count > height # we make sure the cursor is on the screen, and that we're # using all of the screen if we can @@ -274,56 +339,115 @@ def refresh(self, screen, c_xy): offset = cy elif cy >= offset + height: offset = cy - height + 1 - elif offset > 0 and len(screen) < offset + height: - offset = max(len(screen) - height, 0) - screen.append("") + elif offset > 0 and line_count < offset + height: + offset = max(line_count - height, 0) + next_lines.append(EMPTY_RENDER_LINE) - oldscr = self.screen[old_offset : old_offset + height] - newscr = screen[offset : offset + height] + oldscr = previous_lines[old_offset : old_offset + height] + newscr = next_lines[offset : offset + height] - # use hardware scrolling if we have it. + reverse_scroll = 0 + forward_scroll = 0 if old_offset > offset and self._ri: + reverse_scroll = old_offset - offset + for _ in range(reverse_scroll): + if oldscr: + oldscr.pop(-1) + oldscr.insert(0, EMPTY_RENDER_LINE) + elif old_offset < offset and self._ind: + forward_scroll = offset - old_offset + for _ in range(forward_scroll): + if oldscr: + oldscr.pop(0) + oldscr.append(EMPTY_RENDER_LINE) + + line_updates: list[LineUpdate] = [] + px, _ = self.posxy + for y, oldline, newline in zip(range(offset, offset + height), oldscr, newscr): + update = self.__plan_changed_line(y, oldline, newline, px) + if update is not None: + line_updates.append(update) + + cleared_lines = tuple(range(offset + len(newscr), offset + len(oldscr))) + console_rendered_screen = RenderedScreen(tuple(next_lines), c_xy) + trace( + "unix.refresh plan grow={grow} tall={tall} offset={offset} " + "reverse_scroll={reverse_scroll} forward_scroll={forward_scroll} " + "updates={updates} clears={clears}", + grow=grow_lines, + tall=use_tall_mode, + offset=offset, + reverse_scroll=reverse_scroll, + forward_scroll=forward_scroll, + updates=len(line_updates), + clears=len(cleared_lines), + ) + return UnixRefreshPlan( + grow_lines=grow_lines, + use_tall_mode=use_tall_mode, + offset=offset, + reverse_scroll=reverse_scroll, + forward_scroll=forward_scroll, + line_updates=tuple(line_updates), + cleared_lines=cleared_lines, + rendered_screen=console_rendered_screen, + cursor=(cx, cy), + ) + + def __apply_refresh_plan(self, plan: UnixRefreshPlan) -> None: + cx, cy = plan.cursor + trace( + "unix.refresh apply cursor={cursor} updates={updates} clears={clears}", + cursor=plan.cursor, + updates=len(plan.line_updates), + clears=len(plan.cleared_lines), + ) + visual_style = self.begin_redraw_visualization() + screen_line_count = len(self._rendered_screen.composed_lines) + + for _ in range(plan.grow_lines): + self.__hide_cursor() + if screen_line_count: + self.__move(0, screen_line_count - 1) + self.__write("\n") + self.posxy = 0, screen_line_count + screen_line_count += 1 + + if plan.use_tall_mode and not self.__gone_tall: + self.__gone_tall = True + self.__move = self.__move_tall + + old_offset = self.__offset + if plan.reverse_scroll: self.__hide_cursor() self.__write_code(self._cup, 0, 0) self.posxy = 0, old_offset - for i in range(old_offset - offset): + for _ in range(plan.reverse_scroll): self.__write_code(self._ri) - oldscr.pop(-1) - oldscr.insert(0, "") - elif old_offset < offset and self._ind: + elif plan.forward_scroll: self.__hide_cursor() self.__write_code(self._cup, self.height - 1, 0) self.posxy = 0, old_offset + self.height - 1 - for i in range(offset - old_offset): + for _ in range(plan.forward_scroll): self.__write_code(self._ind) - oldscr.pop(0) - oldscr.append("") - self.__offset = offset + self.__offset = plan.offset - for ( - y, - oldline, - newline, - ) in zip(range(offset, offset + height), oldscr, newscr): - if oldline != newline: - self.__write_changed_line(y, oldline, newline, px) + for update in plan.line_updates: + self.__apply_line_update(update, visual_style) - y = len(newscr) - while y < len(oldscr): + for y in plan.cleared_lines: self.__hide_cursor() self.__move(0, y) self.posxy = 0, y self.__write_code(self._el) - y += 1 self.__show_cursor() - - self.screen = screen.copy() self.move_cursor(cx, cy) self.flushoutput() + self.sync_rendered_screen(plan.rendered_screen, self.posxy) - def move_cursor(self, x, y): + def move_cursor(self, x: int, y: int) -> None: """ Move the cursor to the specified position on the screen. @@ -332,16 +456,25 @@ def move_cursor(self, x, y): - y (int): Y coordinate. """ if y < self.__offset or y >= self.__offset + self.height: - self.event_queue.insert(Event("scroll", None)) + trace( + "unix.move_cursor offscreen x={x} y={y} offset={offset} height={height}", + x=x, + y=y, + offset=self.__offset, + height=self.height, + ) + self.event_queue.insert(Event("scroll", "")) else: + trace("unix.move_cursor x={x} y={y}", x=x, y=y) self.__move(x, y) self.posxy = x, y self.flushoutput() - def prepare(self): + def prepare(self) -> None: """ Prepare the console for input/output operations. """ + trace("unix.prepare") self.__buffer = [] self.__svtermstate = tcgetattr(self.input_fd) @@ -353,21 +486,22 @@ def prepare(self): raw.iflag |= termios.BRKINT raw.lflag &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN) raw.lflag |= termios.ISIG - raw.cc[termios.VMIN] = 1 - raw.cc[termios.VTIME] = 0 + raw.cc[termios.VMIN] = b"\x01" + raw.cc[termios.VTIME] = b"\x00" self.__input_fd_set(raw) - # In macOS terminal we need to deactivate line wrap via ANSI escape code + # Apple Terminal will re-wrap lines for us unless we preempt the + # damage. if self.is_apple_terminal: os.write(self.output_fd, b"\033[?7l") - self.screen = [] self.height, self.width = self.getheightwidth() self.posxy = 0, 0 - self.__gone_tall = 0 + self.__gone_tall = False self.__move = self.__move_short self.__offset = 0 + self.sync_rendered_screen(RenderedScreen.empty(), self.posxy) self.__maybe_write_code(self._smkx) @@ -378,10 +512,11 @@ def prepare(self): self.__enable_bracketed_paste() - def restore(self): + def restore(self) -> None: """ Restore the console to the default state """ + trace("unix.restore") self.__disable_bracketed_paste() self.__maybe_write_code(self._rmkx) self.flushoutput() @@ -446,7 +581,7 @@ def wait(self, timeout: float | None = None) -> bool: or bool(self.pollob.poll(timeout)) ) - def set_cursor_vis(self, visible): + def set_cursor_vis(self, visible: bool) -> None: """ Set the visibility of the cursor. @@ -514,8 +649,9 @@ def finish(self): """ Finish console operations and flush the output buffer. """ - y = len(self.screen) - 1 - while y >= 0 and not self.screen[y]: + rendered_lines = self._rendered_screen.composed_lines + y = len(rendered_lines) - 1 + while y >= 0 and not rendered_lines[y].text: y -= 1 self.__move(0, min(y, self.height + self.__offset - 1)) self.__write("\n\r") @@ -542,7 +678,7 @@ def getpending(self): while not self.event_queue.empty(): e2 = self.event_queue.get() e.data += e2.data - e.raw += e.raw + e.raw += e2.raw amount = struct.unpack("i", ioctl(self.input_fd, FIONREAD, b"\0\0\0\0"))[0] trace("getpending({a})", a=amount) @@ -566,7 +702,7 @@ def getpending(self): while not self.event_queue.empty(): e2 = self.event_queue.get() e.data += e2.data - e.raw += e.raw + e.raw += e2.raw amount = 10000 raw = self.__read(amount) @@ -579,11 +715,12 @@ def clear(self): """ Clear the console screen. """ + trace("unix.clear") self.__write_code(self._clear) - self.__gone_tall = 1 + self.__gone_tall = True self.__move = self.__move_tall self.posxy = 0, 0 - self.screen = [] + self.sync_rendered_screen(RenderedScreen.empty(), self.posxy) @property def input_hook(self): @@ -634,98 +771,178 @@ def __setup_movement(self): self.__move = self.__move_short - def __write_changed_line(self, y, oldline, newline, px_coord): - # this is frustrating; there's no reason to test (say) - # self.dch1 inside the loop -- but alternative ways of - # structuring this function are equally painful (I'm trying to - # avoid writing code generators these days...) - minlen = min(wlen(oldline), wlen(newline)) - x_pos = 0 - x_coord = 0 - - px_pos = 0 - j = 0 - for c in oldline: - if j >= px_coord: - break - j += wlen(c) - px_pos += 1 - - # reuse the oldline as much as possible, but stop as soon as we - # encounter an ESCAPE, because it might be the start of an escape - # sequence - while ( - x_coord < minlen - and oldline[x_pos] == newline[x_pos] - and newline[x_pos] != "\x1b" - ): - x_coord += wlen(newline[x_pos]) - x_pos += 1 + @staticmethod + def __cell_index_from_x(line: RenderLine, x_coord: int) -> int: + width = 0 + index = 0 + while index < len(line.cells) and width < x_coord: + width += line.cells[index].width + index += 1 + return index + + def __plan_changed_line( + self, + y: int, + oldline: RenderLine, + newline: RenderLine, + px_coord: int, + ) -> LineUpdate | None: + # NOTE: The shared replace_char / replace_span / rewrite_suffix logic + # is duplicated in WindowsConsole.__plan_changed_line. Keep changes to + # these common cases synchronised between the two files. Yes, this is + # duplicated on purpose; the two backends agree just enough to make a + # shared helper a trap. Unix-only cases (insert_char, delete_then_insert) + # rely on terminal capabilities (ich1/dch1) that are unavailable on + # Windows. + diff = diff_render_lines(oldline, newline) + if diff is None: + return None - # if we need to insert a single character right after the first detected change - if oldline[x_pos:] == newline[x_pos + 1 :] and self.ich1: + start_cell = diff.start_cell + start_x = diff.start_x + + if ( + self.ich1 + and not diff.old_cells + and (visible_new_cells := tuple( + cell for cell in diff.new_cells if cell.width + )) + and len(visible_new_cells) == 1 + and all(cell.width == 0 for cell in diff.new_cells[1:]) + and oldline.cells[start_cell:] == newline.cells[start_cell + 1 :] + ): + px_cell = self.__cell_index_from_x(oldline, px_coord) if ( y == self.posxy[1] - and x_coord > self.posxy[0] - and oldline[px_pos:x_pos] == newline[px_pos + 1 : x_pos + 1] + and start_x > self.posxy[0] + and oldline.cells[px_cell:start_cell] + == newline.cells[px_cell + 1 : start_cell + 1] ): - x_pos = px_pos - x_coord = px_coord - character_width = wlen(newline[x_pos]) - self.__move(x_coord, y) - self.__write_code(self.ich1) - self.__write(newline[x_pos]) - self.posxy = x_coord + character_width, y - - # if it's a single character change in the middle of the line - elif ( - x_coord < minlen - and oldline[x_pos + 1 :] == newline[x_pos + 1 :] - and wlen(oldline[x_pos]) == wlen(newline[x_pos]) + start_cell = px_cell + start_x = px_coord + planned_cells = diff.new_cells + changed_cell = visible_new_cells[0] + return LineUpdate( + kind="insert_char", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=planned_cells, + char_width=changed_cell.width, + reset_to_margin=requires_cursor_resync(planned_cells), + ) + + if ( + len(diff.old_cells) == 1 + and len(diff.new_cells) == 1 + and diff.old_cells[0].width == diff.new_cells[0].width ): - character_width = wlen(newline[x_pos]) - self.__move(x_coord, y) - self.__write(newline[x_pos]) - self.posxy = x_coord + character_width, y - - # if this is the last character to fit in the line and we edit in the middle of the line - elif ( + planned_cells = diff.new_cells + changed_cell = planned_cells[0] + return LineUpdate( + kind="replace_char", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=planned_cells, + char_width=changed_cell.width, + reset_to_margin=requires_cursor_resync(planned_cells), + ) + + if diff.old_changed_width == diff.new_changed_width: + planned_cells = diff.new_cells + return LineUpdate( + kind="replace_span", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=planned_cells, + char_width=diff.new_changed_width, + reset_to_margin=requires_cursor_resync(planned_cells), + ) + + if ( self.dch1 and self.ich1 - and wlen(newline) == self.width - and x_coord < wlen(newline) - 2 - and newline[x_pos + 1 : -1] == oldline[x_pos:-2] + and newline.width == self.width + and start_x < newline.width - 2 + and newline.cells[start_cell + 1 : -1] == oldline.cells[start_cell:-2] ): + planned_cells = (newline.cells[start_cell],) + changed_cell = planned_cells[0] + return LineUpdate( + kind="delete_then_insert", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=planned_cells, + char_width=changed_cell.width, + reset_to_margin=requires_cursor_resync(planned_cells), + ) + + suffix_cells = newline.cells[start_cell:] + return LineUpdate( + kind="rewrite_suffix", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=suffix_cells, + char_width=sum(cell.width for cell in suffix_cells), + clear_eol=oldline.width > newline.width, + reset_to_margin=requires_cursor_resync(suffix_cells), + ) + + def __apply_line_update( + self, + update: LineUpdate, + visual_style: str | None = None, + ) -> None: + text = render_cells(update.cells, visual_style) if visual_style else update.text + trace( + "unix.refresh update kind={kind} y={y} x={x} text={text} " + "clear_eol={clear_eol} reset_to_margin={reset}", + kind=update.kind, + y=update.y, + x=update.start_x, + text=trace_text(text), + clear_eol=update.clear_eol, + reset=update.reset_to_margin, + ) + if update.kind == "insert_char": + self.__move(update.start_x, update.y) + self.__write_code(self.ich1) + self.__write(text) + self.posxy = update.start_x + update.char_width, update.y + elif update.kind in {"replace_char", "replace_span"}: + self.__move(update.start_x, update.y) + self.__write(text) + self.posxy = update.start_x + update.char_width, update.y + elif update.kind == "delete_then_insert": self.__hide_cursor() - self.__move(self.width - 2, y) - self.posxy = self.width - 2, y + self.__move(self.width - 2, update.y) + self.posxy = self.width - 2, update.y self.__write_code(self.dch1) - - character_width = wlen(newline[x_pos]) - self.__move(x_coord, y) + self.__move(update.start_x, update.y) self.__write_code(self.ich1) - self.__write(newline[x_pos]) - self.posxy = character_width + 1, y - + self.__write(text) + self.posxy = update.start_x + update.char_width, update.y else: self.__hide_cursor() - self.__move(x_coord, y) - if wlen(oldline) > wlen(newline): + self.__move(update.start_x, update.y) + if update.clear_eol: self.__write_code(self._el) - self.__write(newline[x_pos:]) - self.posxy = wlen(newline), y + self.__write(text) + self.posxy = update.start_x + update.char_width, update.y - if "\x1b" in newline: - # ANSI escape characters are present, so we can't assume - # anything about the position of the cursor. Moving the cursor - # to the left margin should work to get to a known position. - self.move_cursor(0, y) + if update.reset_to_margin: + # Non-SGR terminal controls can affect the cursor position. + self.move_cursor(0, update.y) def __write(self, text): - self.__buffer.append((text, 0)) + self.__buffer.append((text, False)) def __write_code(self, fmt, *args): - self.__buffer.append((terminfo.tparm(fmt, *args), 1)) + self.__buffer.append((terminfo.tparm(fmt, *args), True)) def __maybe_write_code(self, fmt, *args): if fmt: @@ -776,30 +993,38 @@ def __move_tall(self, x, y): self.__write_code(self._cup, y - self.__offset, x) def __sigwinch(self, signum, frame): - self.height, self.width = self.getheightwidth() - self.event_queue.insert(Event("resize", None)) + self.event_queue.insert(Event("resize", "")) def __hide_cursor(self): if self.cursor_visible: self.__maybe_write_code(self._civis) - self.cursor_visible = 0 + self.cursor_visible = False def __show_cursor(self): if not self.cursor_visible: self.__maybe_write_code(self._cnorm) - self.cursor_visible = 1 + self.cursor_visible = True def repaint(self): + composed = self._rendered_screen.composed_lines + trace( + "unix.repaint gone_tall={gone_tall} screen_lines={lines} offset={offset}", + gone_tall=self.__gone_tall, + lines=len(composed), + offset=self.__offset, + ) if not self.__gone_tall: self.posxy = 0, self.posxy[1] self.__write("\r") - ns = len(self.screen) * ["\000" * self.width] - self.screen = ns + ns = len(composed) * ["\000" * self.width] else: self.posxy = 0, self.__offset self.__move(0, self.__offset) ns = self.height * ["\000" * self.width] - self.screen = ns + self.sync_rendered_screen( + RenderedScreen.from_screen_lines(ns, self.posxy), + self.posxy, + ) def __tputs(self, fmt, prog=delayprog): """A Python implementation of the curses tputs function; the diff --git a/Lib/_pyrepl/utils.py b/Lib/_pyrepl/utils.py index 7175d57a9e319e..b50426c31ead53 100644 --- a/Lib/_pyrepl/utils.py +++ b/Lib/_pyrepl/utils.py @@ -9,6 +9,7 @@ import _colorize from collections import deque +from dataclasses import dataclass from io import StringIO from tokenize import TokenInfo as TI from typing import Iterable, Iterator, Match, NamedTuple, Self @@ -16,6 +17,7 @@ from .types import CharBuffer, CharWidths from .trace import trace + ANSI_ESCAPE_SEQUENCE = re.compile(r"\x1b\[[ -@]*[A-~]") ZERO_WIDTH_BRACKET = re.compile(r"\x01.*?\x02") ZERO_WIDTH_TRANS = str.maketrans({"\x01": "", "\x02": ""}) @@ -59,6 +61,21 @@ class ColorSpan(NamedTuple): tag: str +class StyledChar(NamedTuple): + text: str + width: int + tag: str | None = None + + +def _ascii_control_repr(c: str) -> str | None: + code = ord(c) + if code < 32: + return "^" + chr(code + 64) + if code == 127: + return "^?" + return None + + @functools.cache def str_width(c: str) -> int: if ord(c) < 128: @@ -286,6 +303,61 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool: return False +def iter_display_chars( + buffer: str, + colors: list[ColorSpan] | None = None, + start_index: int = 0, +) -> Iterator[StyledChar]: + """Yield visible display characters with widths and semantic color tags. + + Note: ``colors`` is consumed in place as spans are processed -- callers + that split a buffer across multiple calls rely on this mutation to track + which spans have already been handled. + """ + + if not buffer: + return + + color_idx = 0 + if colors: + while color_idx < len(colors) and colors[color_idx].span.end < start_index: + color_idx += 1 + + active_tag = None + if colors and color_idx < len(colors) and colors[color_idx].span.start < start_index: + active_tag = colors[color_idx].tag + + for i, c in enumerate(buffer, start_index): + if colors and color_idx < len(colors) and colors[color_idx].span.start == i: + active_tag = colors[color_idx].tag + + if control := _ascii_control_repr(c): + text = control + width = len(control) + elif ord(c) < 128: + text = c + width = 1 + elif unicodedata.category(c).startswith("C"): + text = r"\u%04x" % ord(c) + width = len(text) + else: + text = c + width = str_width(c) + + yield StyledChar(text, width, active_tag) + + if colors and color_idx < len(colors) and colors[color_idx].span.end == i: + color_idx += 1 + active_tag = None + # Check if the next span starts at the same position + if color_idx < len(colors) and colors[color_idx].span.start == i: + active_tag = colors[color_idx].tag + + # Remove consumed spans so callers see the mutation + if color_idx > 0 and colors: + del colors[:color_idx] + + def disp_str( buffer: str, colors: list[ColorSpan] | None = None, @@ -321,53 +393,18 @@ def disp_str( (['\x1b[1;34mw', 'h', 'i', 'l', 'e\x1b[0m', ' ', '1', ':'], [1, 1, 1, 1, 1, 1, 1, 1]) """ + styled_chars = list(iter_display_chars(buffer, colors, start_index)) chars: CharBuffer = [] char_widths: CharWidths = [] - - if not buffer: - return chars, char_widths - - while colors and colors[0].span.end < start_index: - # move past irrelevant spans - colors.pop(0) - theme = THEME(force_color=force_color) - pre_color = "" - post_color = "" - if colors and colors[0].span.start < start_index: - # looks like we're continuing a previous color (e.g. a multiline str) - pre_color = theme[colors[0].tag] - - for i, c in enumerate(buffer, start_index): - if colors and colors[0].span.start == i: # new color starts now - pre_color = theme[colors[0].tag] - if c == "\x1a": # CTRL-Z on Windows - chars.append(c) - char_widths.append(2) - elif ord(c) < 128: - chars.append(c) - char_widths.append(1) - elif unicodedata.category(c).startswith("C"): - c = r"\u%04x" % ord(c) - chars.append(c) - char_widths.append(len(c)) - else: - chars.append(c) - char_widths.append(str_width(c)) - - if colors and colors[0].span.end == i: # current color ends now - post_color = theme.reset - colors.pop(0) - - chars[-1] = pre_color + chars[-1] + post_color - pre_color = "" - post_color = "" - - if colors and colors[0].span.start < i and colors[0].span.end > i: - # even though the current color should be continued, reset it for now. - # the next call to `disp_str()` will revive it. - chars[-1] += theme.reset + for index, styled_char in enumerate(styled_chars): + previous_tag = styled_chars[index - 1].tag if index else None + next_tag = styled_chars[index + 1].tag if index + 1 < len(styled_chars) else None + prefix = theme[styled_char.tag] if styled_char.tag and styled_char.tag != previous_tag else "" + suffix = theme.reset if styled_char.tag and styled_char.tag != next_tag else "" + chars.append(prefix + styled_char.text + suffix) + char_widths.append(styled_char.width) return chars, char_widths @@ -385,13 +422,35 @@ def prev_next_window[T]( """ iterator = iter(iterable) - window = deque((None, next(iterator)), maxlen=3) + try: + first = next(iterator) + except StopIteration: + return + window = deque((None, first), maxlen=3) try: for x in iterator: window.append(x) yield tuple(window) - except Exception: - raise finally: window.append(None) yield tuple(window) + + +@dataclass(frozen=True, slots=True) +class StyleRef: + tag: str | None = None # From THEME().syntax, e.g. "keyword", "builtin" + sgr: str = "" + + @classmethod + def from_tag(cls, tag: str, sgr: str = "") -> Self: + return cls(tag=tag, sgr=sgr) + + @classmethod + def from_sgr(cls, sgr: str) -> Self: + if not sgr: + return cls() + return cls(sgr=sgr) + + @property + def is_plain(self) -> bool: + return self.tag is None and not self.sgr diff --git a/Lib/_pyrepl/windows_console.py b/Lib/_pyrepl/windows_console.py index cb1834168e881c..c1f9a19545d35f 100644 --- a/Lib/_pyrepl/windows_console.py +++ b/Lib/_pyrepl/windows_console.py @@ -25,6 +25,7 @@ import ctypes import types +from dataclasses import dataclass from ctypes.wintypes import ( _COORD, WORD, @@ -37,9 +38,18 @@ SHORT, ) from ctypes import Structure, POINTER, Union +from typing import TYPE_CHECKING from .console import Event, Console -from .trace import trace -from .utils import wlen +from .render import ( + EMPTY_RENDER_LINE, + LineUpdate, + RenderLine, + RenderedScreen, + requires_cursor_resync, + diff_render_lines, + render_cells, +) +from .trace import trace, trace_text from .windows_eventqueue import EventQueue try: @@ -63,8 +73,6 @@ def __init__(self, err: int | None, descr: str | None = None) -> None: except ImportError: nt = None -TYPE_CHECKING = False - if TYPE_CHECKING: from typing import IO @@ -123,6 +131,17 @@ def __init__(self, err: int | None, descr: str | None = None) -> None: class _error(Exception): pass + +@dataclass(frozen=True, slots=True) +class WindowsRefreshPlan: + grow_lines: int + offset: int + scroll_lines: int + line_updates: tuple[LineUpdate, ...] + cleared_lines: tuple[int, ...] + rendered_screen: RenderedScreen + cursor: tuple[int, int] + def _supports_vt(): try: return nt._supports_virtual_terminal() @@ -159,7 +178,6 @@ def __init__( ): raise WinError(get_last_error()) - self.screen: list[str] = [] self.width = 80 self.height = 25 self.__offset = 0 @@ -170,74 +188,124 @@ def __init__( # Console I/O is redirected, fallback... self.out = None - def refresh(self, screen: list[str], c_xy: tuple[int, int]) -> None: + def refresh(self, rendered_screen: RenderedScreen) -> None: """ Refresh the console screen. Parameters: - - screen (list): List of strings representing the screen contents. - - c_xy (tuple): Cursor position (x, y) on the screen. + - rendered_screen: Structured rendered screen contents and cursor. """ - cx, cy = c_xy - - while len(self.screen) < min(len(screen), self.height): - self._hide_cursor() - if self.screen: - self._move_relative(0, len(self.screen) - 1) - self.__write("\n") - self.posxy = 0, len(self.screen) - self.screen.append("") + c_xy = rendered_screen.cursor + trace( + "windows.refresh start cursor={cursor} lines={lines} prev_lines={prev_lines} " + "offset={offset} posxy={posxy}", + cursor=c_xy, + lines=len(rendered_screen.composed_lines), + prev_lines=len(self._rendered_screen.composed_lines), + offset=self.__offset, + posxy=self.posxy, + ) + plan = self.__plan_refresh(rendered_screen, c_xy) + self.__apply_refresh_plan(plan) - px, py = self.posxy - old_offset = offset = self.__offset + def __plan_refresh( + self, + rendered_screen: RenderedScreen, + c_xy: tuple[int, int], + ) -> WindowsRefreshPlan: + cx, cy = c_xy height = self.height + old_offset = offset = self.__offset + prev_composed = self._rendered_screen.composed_lines + previous_lines = list(prev_composed) + next_lines = list(rendered_screen.composed_lines) + line_count = len(next_lines) + + grow_lines = max( + min(line_count, height) - len(prev_composed), + 0, + ) + previous_lines.extend([EMPTY_RENDER_LINE] * grow_lines) - # we make sure the cursor is on the screen, and that we're - # using all of the screen if we can + scroll_lines = 0 if cy < offset: offset = cy elif cy >= offset + height: offset = cy - height + 1 scroll_lines = offset - old_offset + previous_lines.extend([EMPTY_RENDER_LINE] * scroll_lines) + elif offset > 0 and line_count < offset + height: + offset = max(line_count - height, 0) + next_lines.append(EMPTY_RENDER_LINE) + + oldscr = previous_lines[old_offset : old_offset + height] + newscr = next_lines[offset : offset + height] + + line_updates: list[LineUpdate] = [] + px, _ = self.posxy + for y, oldline, newline in zip(range(offset, offset + height), oldscr, newscr): + update = self.__plan_changed_line(y, oldline, newline, px) + if update is not None: + line_updates.append(update) + + cleared_lines = tuple(range(offset + len(newscr), offset + len(oldscr))) + console_rendered_screen = RenderedScreen(tuple(next_lines), c_xy) + trace( + "windows.refresh plan grow={grow} offset={offset} scroll_lines={scroll_lines} " + "updates={updates} clears={clears}", + grow=grow_lines, + offset=offset, + scroll_lines=scroll_lines, + updates=len(line_updates), + clears=len(cleared_lines), + ) + return WindowsRefreshPlan( + grow_lines=grow_lines, + offset=offset, + scroll_lines=scroll_lines, + line_updates=tuple(line_updates), + cleared_lines=cleared_lines, + rendered_screen=console_rendered_screen, + cursor=(cx, cy), + ) - # Scrolling the buffer as the current input is greater than the visible - # portion of the window. We need to scroll the visible portion and the - # entire history - self._scroll(scroll_lines, self._getscrollbacksize()) - self.posxy = self.posxy[0], self.posxy[1] + scroll_lines - self.__offset += scroll_lines + def __apply_refresh_plan(self, plan: WindowsRefreshPlan) -> None: + cx, cy = plan.cursor + trace( + "windows.refresh apply cursor={cursor} updates={updates} clears={clears}", + cursor=plan.cursor, + updates=len(plan.line_updates), + clears=len(plan.cleared_lines), + ) + visual_style = self.begin_redraw_visualization() + screen_line_count = len(self._rendered_screen.composed_lines) - for i in range(scroll_lines): - self.screen.append("") - elif offset > 0 and len(screen) < offset + height: - offset = max(len(screen) - height, 0) - screen.append("") + for _ in range(plan.grow_lines): + self._hide_cursor() + if screen_line_count: + self._move_relative(0, screen_line_count - 1) + self.__write("\n") + self.posxy = 0, screen_line_count + screen_line_count += 1 - oldscr = self.screen[old_offset : old_offset + height] - newscr = screen[offset : offset + height] + if plan.scroll_lines: + self._scroll(plan.scroll_lines, self._getscrollbacksize()) + self.posxy = self.posxy[0], self.posxy[1] + plan.scroll_lines - self.__offset = offset + self.__offset = plan.offset self._hide_cursor() - for ( - y, - oldline, - newline, - ) in zip(range(offset, offset + height), oldscr, newscr): - if oldline != newline: - self.__write_changed_line(y, oldline, newline, px) - - y = len(newscr) - while y < len(oldscr): + for update in plan.line_updates: + self.__apply_line_update(update, visual_style) + + for y in plan.cleared_lines: self._move_relative(0, y) self.posxy = 0, y self._erase_to_end() - y += 1 self._show_cursor() - - self.screen = screen self.move_cursor(cx, cy) + self.sync_rendered_screen(plan.rendered_screen, self.posxy) @property def input_hook(self): @@ -246,37 +314,98 @@ def input_hook(self): if nt is not None and nt._is_inputhook_installed(): return nt._inputhook - def __write_changed_line( - self, y: int, oldline: str, newline: str, px_coord: int - ) -> None: - minlen = min(wlen(oldline), wlen(newline)) - x_pos = 0 - x_coord = 0 - - # reuse the oldline as much as possible, but stop as soon as we - # encounter an ESCAPE, because it might be the start of an escape - # sequence - while ( - x_coord < minlen - and oldline[x_pos] == newline[x_pos] - and newline[x_pos] != "\x1b" + def __plan_changed_line( # keep in sync with UnixConsole.__plan_changed_line + self, + y: int, + oldline: RenderLine, + newline: RenderLine, + px_coord: int, + ) -> LineUpdate | None: + diff = diff_render_lines(oldline, newline) + if diff is None: + return None + + start_cell = diff.start_cell + start_x = diff.start_x + if ( + len(diff.old_cells) == 1 + and len(diff.new_cells) == 1 + and diff.old_cells[0].width == diff.new_cells[0].width ): - x_coord += wlen(newline[x_pos]) - x_pos += 1 + changed_cell = diff.new_cells[0] + # Ctrl-Z (SUB) can reach here via RenderLine.from_rendered_text() + # for prompt/message lines, which bypasses iter_display_chars(). + # On Windows, raw \x1a causes console cursor anomalies, so we + # force a cursor resync when it appears. + return LineUpdate( + kind="replace_char", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=diff.new_cells, + char_width=changed_cell.width, + reset_to_margin=( + requires_cursor_resync(diff.new_cells) + or "\x1a" in changed_cell.text + ), + ) + + if diff.old_changed_width == diff.new_changed_width: + return LineUpdate( + kind="replace_span", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=diff.new_cells, + char_width=diff.new_changed_width, + reset_to_margin=( + requires_cursor_resync(diff.new_cells) + or any("\x1a" in cell.text for cell in diff.new_cells) + ), + ) + + suffix_cells = newline.cells[start_cell:] + return LineUpdate( + kind="rewrite_suffix", + y=y, + start_cell=start_cell, + start_x=start_x, + cells=suffix_cells, + char_width=sum(cell.width for cell in suffix_cells), + clear_eol=oldline.width > newline.width, + reset_to_margin=( + requires_cursor_resync(suffix_cells) + or any("\x1a" in cell.text for cell in suffix_cells) + ), + ) - self._hide_cursor() - self._move_relative(x_coord, y) - if wlen(oldline) > wlen(newline): + def __apply_line_update( + self, + update: LineUpdate, + visual_style: str | None = None, + ) -> None: + text = render_cells(update.cells, visual_style) if visual_style else update.text + trace( + "windows.refresh update kind={kind} y={y} x={x} text={text} " + "clear_eol={clear_eol} reset_to_margin={reset}", + kind=update.kind, + y=update.y, + x=update.start_x, + text=trace_text(text), + clear_eol=update.clear_eol, + reset=update.reset_to_margin, + ) + original_y = self.posxy[1] + self._move_relative(update.start_x, update.y) + if update.clear_eol: self._erase_to_end() - self.__write(newline[x_pos:]) - self.posxy = min(wlen(newline), self.width - 1), y + self.__write(text) + self.posxy = min(update.start_x + update.char_width, self.width - 1), update.y - if "\x1b" in newline or y != self.posxy[1] or '\x1a' in newline: - # ANSI escape characters are present, so we can't assume - # anything about the position of the cursor. Moving the cursor - # to the left margin should work to get to a known position. - self.move_cursor(0, y) + if update.reset_to_margin or update.y != original_y: + # Non-SGR terminal controls or vertical movement require a cursor sync. + self.move_cursor(0, update.y) def _scroll( self, top: int, bottom: int, left: int | None = None, right: int | None = None @@ -317,7 +446,7 @@ def _disable_bracketed_paste(self) -> None: def __write(self, text: str) -> None: if "\x1a" in text: - text = ''.join(["^Z" if x == '\x1a' else x for x in text]) + text = text.replace("\x1a", "^Z") if self.out is not None: self.out.write(text.encode(self.encoding, "replace")) @@ -336,12 +465,12 @@ def _erase_to_end(self) -> None: self.__write(ERASE_IN_LINE) def prepare(self) -> None: - trace("prepare") - self.screen = [] + trace("windows.prepare") self.height, self.width = self.getheightwidth() self.posxy = 0, 0 self.__offset = 0 + self.sync_rendered_screen(RenderedScreen.empty(), self.posxy) if self.__vt_support: if not SetConsoleMode(InHandle, self.__original_input_mode | ENABLE_VIRTUAL_TERMINAL_INPUT): @@ -349,6 +478,7 @@ def prepare(self) -> None: self._enable_bracketed_paste() def restore(self) -> None: + trace("windows.restore") if self.__vt_support: # Recover to original mode before running REPL self._disable_bracketed_paste() @@ -374,8 +504,16 @@ def move_cursor(self, x: int, y: int) -> None: raise ValueError(f"Bad cursor position {x}, {y}") if y < self.__offset or y >= self.__offset + self.height: + trace( + "windows.move_cursor offscreen x={x} y={y} offset={offset} height={height}", + x=x, + y=y, + offset=self.__offset, + height=self.height, + ) self.event_queue.insert(Event("scroll", "")) else: + trace("windows.move_cursor x={x} y={y}", x=x, y=y) self._move_relative(x, y) self.posxy = x, y @@ -496,15 +634,17 @@ def beep(self) -> None: def clear(self) -> None: """Wipe the screen""" + trace("windows.clear") self.__write(CLEAR) self.posxy = 0, 0 - self.screen = [] + self.sync_rendered_screen(RenderedScreen.empty(), self.posxy) def finish(self) -> None: """Move the cursor to the end of the display and otherwise get ready for end. XXX could be merged with restore? Hmm.""" - y = len(self.screen) - 1 - while y >= 0 and not self.screen[y]: + rendered_lines = self._rendered_screen.composed_lines + y = len(rendered_lines) - 1 + while y >= 0 and not rendered_lines[y].text: y -= 1 self._move_relative(0, min(y, self.height + self.__offset - 1)) self.__write("\r\n") @@ -546,7 +686,7 @@ def getpending(self) -> Event: # ignore SHIFT_PRESSED and special keys continue if ch == "\r": - ch += "\n" + ch = "\n" e.data += ch return e @@ -573,6 +713,7 @@ def wait(self, timeout: float | None) -> bool: ) def repaint(self) -> None: + trace("windows.repaint unsupported") raise NotImplementedError("No repaint support") diff --git a/Lib/configparser.py b/Lib/configparser.py index d435a5c2fe0da2..e76647d339e913 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -613,7 +613,9 @@ class RawConfigParser(MutableMapping): \] # ] """ _OPT_TMPL = r""" - (?P